Computer Science Canada Collision Response Help (AABB) |
Author: | tiedye1 [ 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 |
Author: | tiedye1 [ Tue Oct 15, 2013 6:48 pm ] |
Post subject: | RE:Collision Response Help (AABB) |
Can anyone offer and guidance? |
Author: | Raknarg [ 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 |
Author: | tiedye1 [ Tue Oct 15, 2013 8:46 pm ] |
Post subject: | RE:Collision Response Help (AABB) |
Alright |
Author: | Raknarg [ 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? |
Author: | tiedye1 [ 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. |
Author: | Raknarg [ 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? |
Author: | tiedye1 [ 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. |