How can i stop the player from moving when it collides with another hitbox?
I'm trying to figure out how to make my player collide with walls and other assets like furniture. I'm basing the collision off of the sprite to sprite collision library/demo(Huge thank you to "this_name_is_taken"). I can detect collisions just fine :D, but i don't know how i would go about making the player stop when it collides with a hit box.
I've been stuck on this all day XD. Any help is very much appreciated
Thank you for reading
Maybe add a custom variable like
canMove = true
Now set it to 'false' on collision. Wrap an if loop around your movement function so that it only processes on canMove==true.
Just one idea without knowing the specific structure of your code
Or run the collision check before the movement and skip it if needed
"Maybe add a custom variable like canMove = true
Now set it to 'false' on collision. Wrap an if loop around your movement function so that it only processes on canMove==true."
That could work. I would just need to set a loop for all four vectors that would end when you move in one of the other 3 vectors, so that you can't get stuck to the wall forever XD
In that case integrate it into the movement.
Get the direction, 'look ahead' if there would be a collision in that direction and only move if not.
that's even better, thank you!