Jump to content
  • Advertisement
Sign in to follow this  
kevdotbadger

Reacting to a 2d collision

This topic is 2371 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

Hay, I've got 3 blocks. One is moveable with WASD and the other 2 are non-moveable. They all have bounding boxes and I've programmed it so that when 2 shapes intersects the moveable block gets moved back based on the width and height of the intersection. This works perectly, but only if collides with 1 block.

I hold the 2 non-moveable blocks inside a vector, then I'm looping through the vector and checking the collisions.

I've got 3 images to illustrate my problem.

Hmhk8.png
This shows the layout, the red block is moveable, basically I'm going to be heading in an up-left direction. Holding the W and A keys.

ROrJf.png
This shows that the blocks collide correctly at this point, I am still holding W and A at this point.
ReIMU.png
I am continuing to hold W and A but the red block no longer heads in that direction. It gets stuck here. The problem, i think, is that the 2 green blocks are arguing with repositioning the red block based on the intersection.

How do I deal with this? Is there any example code I can look at to help me with this problem?

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!