Jump to content
  • Advertisement
Sign in to follow this  
D3DXVECTOR3

Collision detected between 2 sprites, now what!?

This topic is 4745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
There are many ways of doing this. Here is the method that I would use:-

Check the directions that the sprites were moving in. If sprite X was moving away from sprite Y and there was a collision between them, then sprite Y would have slammed into sprite X.

Share this post


Link to post
Share on other sites
If you check for collisions within your movement code then the object you checked is the initiator of the collision.

Share this post


Link to post
Share on other sites
Well the collsion detection works by checking if the sprites are on top of eachother. It needs to be like this: If there is collsion check who slammed into who

Share this post


Link to post
Share on other sites
Most movement routines move the sprite to a NEW location and keep the OLD location, then check for collisions and only move if the there are no collisions. In this case (where you check for the NEW location collision) it is always the initiator of the move that caused the collision because at that point in time nothing else is moving.

How does your movement code work?

If you just move the position of the sprite and then check for collisions I'd suggest changing to the above method.

Share this post


Link to post
Share on other sites
Quote:
Original post by D3DXVECTOR3
Well the collsion detection works by checking if the sprites are on top of eachother. It needs to be like this: If there is collsion check who slammed into who


It depends on what you mean by "who slammed into who". What does it mean in terms of gameplay? (What difference does it make?) If it's for physics simulation, for example, to chenge the speeds, then you don't really need to know who bumped into whom, because you can just use the difference of the pre-bump speeds to calculate new velocities. If it's some other game mechanic, then I imagine the particulars would determine your testing procedure.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!