https://www.mediafire.com/?eqh1pp3phac22cj
I decided to try to work on making a custom collision detector/resolver and I ran into a problem that I can not fix without help.
Can anyone please help? I have been trying to fix it for hours.
Trouble with my collision detector/resolver
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 39
- Joined: Sat Nov 28, 2015 10:13 am
Re: Trouble with my collision detector/resolver
Please help us help you by:
- Attaching the file to the post rather than using file sharing sites.
- Stating what the problem is, what you expect and what is happening instead. Note that only you know how it's supposed to work, so if you don't tell us, we can't distinguish normal from buggy behaviour.
- Specifying what exact area of the code you need help with. You can't expect us to read your full code just to do the debugging for you. Please understand that it's more likely for you to get help if you're more specific, since analysing someone else's code in full may take quite some time that not many have or are willing to spend.
In short, please make it as easy as possible for people to help you.
- Attaching the file to the post rather than using file sharing sites.
- Stating what the problem is, what you expect and what is happening instead. Note that only you know how it's supposed to work, so if you don't tell us, we can't distinguish normal from buggy behaviour.
- Specifying what exact area of the code you need help with. You can't expect us to read your full code just to do the debugging for you. Please understand that it's more likely for you to get help if you're more specific, since analysing someone else's code in full may take quite some time that not many have or are willing to spend.
In short, please make it as easy as possible for people to help you.
-
- Prole
- Posts: 39
- Joined: Sat Nov 28, 2015 10:13 am
Re: Trouble with my collision detector/resolver
Problem: Collision Detection/Resolver
Function: tile_collisions(id)
Code that is causing the reoccurring problem:
local y_statements = entity_n[3] - block_tile[3] < 95 and entity_n[3] - block_tile[3] > -95
local x_statements = entity_n[2] - block_tile[2] < 52 and entity_n[2] - block_tile[2] > -52
--Collision resolving
if y_statements and x_statements == false then
if entity_n[3] + 95 < block_tile[3] then
entity_n[3] = block_tile[3] + 95
elseif entity_n[3] < block_tile[3] + 95 then
entity_n[3] = block_tile[3] - 95
end
elseif x_statements and y_statements == false then
if entity_n[2] < block_tile[2] + 50 then
entity_n[2] = block_tile[2] + 50
elseif entity_n[2] + 50 > block_tile[2] then
entity_n[2] = block_tile[2] - 50
end
end
Note: entity_n[2] and block_tile[2] are the x coordinates of the objects
entity_n[3] and block_tile[3] are the y coordinates of the objects
Mediafire is reliable for keeping files available for a long time.
Function: tile_collisions(id)
Code that is causing the reoccurring problem:
local y_statements = entity_n[3] - block_tile[3] < 95 and entity_n[3] - block_tile[3] > -95
local x_statements = entity_n[2] - block_tile[2] < 52 and entity_n[2] - block_tile[2] > -52
--Collision resolving
if y_statements and x_statements == false then
if entity_n[3] + 95 < block_tile[3] then
entity_n[3] = block_tile[3] + 95
elseif entity_n[3] < block_tile[3] + 95 then
entity_n[3] = block_tile[3] - 95
end
elseif x_statements and y_statements == false then
if entity_n[2] < block_tile[2] + 50 then
entity_n[2] = block_tile[2] + 50
elseif entity_n[2] + 50 > block_tile[2] then
entity_n[2] = block_tile[2] - 50
end
end
Note: entity_n[2] and block_tile[2] are the x coordinates of the objects
entity_n[3] and block_tile[3] are the y coordinates of the objects
Mediafire is reliable for keeping files available for a long time.
Re: Trouble with my collision detector/resolver
Mediafire is reliable, but also a 3rd-party site which we don't need to rely on. If you upload it right here on the forums, it will always be available when someone reads it here, and if it's offline the post will be offline with it.
If you post code, please use code tags so it is readable.
You still haven't said what the problem is. Please tell us what you expect/want to happen, and what happens instead. Are there error messages?
Also, there is a red notice at the top telling you to read the things to do before making a help thread:
you basically broke all the rules that apply. Noone is going to be super upset you did and we are still going to help you some way or another, but it doesn't help you get an answer or us to be friendly and helpful.
If you post code, please use code tags so it is readable.
You still haven't said what the problem is. Please tell us what you expect/want to happen, and what happens instead. Are there error messages?
Also, there is a red notice at the top telling you to read the things to do before making a help thread:
you basically broke all the rules that apply. Noone is going to be super upset you did and we are still going to help you some way or another, but it doesn't help you get an answer or us to be friendly and helpful.
-
- Prole
- Posts: 39
- Joined: Sat Nov 28, 2015 10:13 am
Re: Trouble with my collision detector/resolver
Alright. Fine. I will just try to do this myself.
Re: Trouble with my collision detector/resolver
I'd suggest eliminating magic numbers and using good variable names as a first step. This should make your code easier to reason about, and when you can reason about it more easily you should be able to find problems more easily.ZBoyer1000 wrote:Alright. Fine. I will just try to do this myself.
Re: Trouble with my collision detector/resolver
It's not that I don't want to help you, it's that you make it hard for me to do so. Yes, I could've taken the time to download, unpack and debug your code, but if you took the time to tell us the actual issue instead you would have a lot more people willing to help you because of the lower effort required to understand your problem alone.ZBoyer1000 wrote:Alright. Fine. I will just try to do this myself.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 160 guests