+ 1
Collision For a JS Game Not Working Properly
I'm working on a small game, just to test out collision and some other new concepts I learned in my course. I added a traffic cone to the game as a barricade, and have been trying to add collision to it for a few days. Today, I finally made a breakthrough with it, but for some reason, it only works when the cone is bumped into from the left. Please help! https://www.sololearn.com/compiler-playground/Wb4LvBYI9HfU
2 Answers
+ 3
Because when the conditions of the outer if are true, all the inner ifs are also true. The value of restrictMovement will be overridden by the last if statement, thus always be either 4, or 0 when the outer conditions are not met.
Btw, your current collision logic allows the images of the scout and the cone slightly overlap, which might not be intended.
0
I am aware of the issue with the scout overlapping, but I wasn't with the if statements. Thank you!