Author |
Message |
tiedye1
![](http://compsci.ca/v3/uploads/user_avatars/197771568354ed6b69b6f2f.png)
|
Posted: Tue Oct 15, 2013 10:21 am Post subject: Collision Response Help (AABB) |
|
|
Hi, lately I have been trying to create a 2D platformer engine in C++ with Direct2D. The problem I am currently having is getting objects that are resting against each other to interact correctly after accelerations like gravity have been applied to them.
Right now I can detect collisions and respond to them correctly (I think) and when objects collide they remember what other objects they're resting against so objects can be pushed by other objects (note that there is no bounce in any collisions so when objects collide they are guaranteed to become resting until something else happens). Every time the simulation advances, the acceleration for objects is applied to their velocities (for example vx += ax * t, where t is time elapsed since last advancement).
After these accelerations are applied, I want to check if any objects that are resting against each other are moving at different speeds than their counterparts and depending on that difference either unlink the two objects so they are no longer resting, or even out their velocities so they are moving at the same speed once again. I am having trouble creating an algorithm that can do this across many resting objects.
Here's a diagram to help explain my problem
![Posted Image, might have been reduced in size. Click Image to view fullscreen. Posted Image, might have been reduced in size. Click Image to view fullscreen.](http://i.imgur.com/cYYsWdE.png) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
tiedye1
![](http://compsci.ca/v3/uploads/user_avatars/197771568354ed6b69b6f2f.png)
|
Posted: Tue Oct 15, 2013 6:48 pm Post subject: RE:Collision Response Help (AABB) |
|
|
Can anyone offer and guidance? |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Tue Oct 15, 2013 8:04 pm Post subject: RE:Collision Response Help (AABB) |
|
|
If you can't get any help here you can also try stack overflow |
|
|
|
|
![](images/spacer.gif) |
tiedye1
![](http://compsci.ca/v3/uploads/user_avatars/197771568354ed6b69b6f2f.png)
|
Posted: Tue Oct 15, 2013 8:46 pm Post subject: RE:Collision Response Help (AABB) |
|
|
Alright |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Tue Oct 15, 2013 9:41 pm Post subject: RE:Collision Response Help (AABB) |
|
|
Collision and physics are probably one of the most annoying things to program imo. Are you familiar with mathematics and programming? |
|
|
|
|
![](images/spacer.gif) |
tiedye1
![](http://compsci.ca/v3/uploads/user_avatars/197771568354ed6b69b6f2f.png)
|
Posted: Wed Oct 16, 2013 8:26 am Post subject: RE:Collision Response Help (AABB) |
|
|
I am familiar with programming and have taken grade 10 math as I am now in grade 11. I do like math a lot so I've gone ahead a bit. I've been programming for quite a while now.
Right now I have already written all the collision detection and response code. I just need to define this function so I can add gravity and other accelerations. |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Wed Oct 16, 2013 9:06 am Post subject: RE:Collision Response Help (AABB) |
|
|
Ok, let's say you have two cubes floating around with no acceleration or gravity and they collide, do they collide properly? Does that part at least work? Or does it work a little differently? |
|
|
|
|
![](images/spacer.gif) |
tiedye1
![](http://compsci.ca/v3/uploads/user_avatars/197771568354ed6b69b6f2f.png)
|
Posted: Wed Oct 16, 2013 12:20 pm Post subject: RE:Collision Response Help (AABB) |
|
|
They do collide properly, and react properly. Each frame it checks when objects collide and if they collide during that frame they advance forward that amount of time and then calculated the reaction for that collision considering the object mass, if its static, axis that the collision occurred on, and objects resting against them. This all works fine (mostly).
I can post my current project if you want, its a visual studio 2012 project. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|