Skip to content

Direction of the collision between rectangles #1983

Answered by jmorel33
ahmedatef286 asked this question in Q&A
Discussion options

You must be logged in to vote

Once you test for collision, just check a.x < b.x where character a's x position would be more left than character b. Super easy in 2D. If you said 3D, you'd have to think of a 3'rd axis. That is my brute force way which always works essentially.

recap;

  1. do you have collision
  2. if, so, which character is more, left or more right, and by how much

If you need to do collision detection for different places, you would have to have multiple hit points on your character and detect which one it was. I wouldn't even use triangle, but a radius. or a box

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ahmedatef286
Comment options

@jmorel33
Comment options

Answer selected by raysan5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants