• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Collisions between 2 objects but primary object not being affected by the other

darijs1

Member
Id like to know if there is any way to make my player be able to knock over other physics objects, but not get affected by that other objects collisions.

For example, if there is a box on the ground and the player jumps on it, instead of landing on the box, the player would land on the ground, and the box would get forced out of the way.

Im sure eventually i can figure something out myself, but i was just wondering if there are any nice ways of doing this?
 

Dupletor

Member
Programming collision is not like having two balls bouncing around in real life.
If you want to have them both affected, you have to individually say they should both be affected.
Code:
if(collision(ball1, ball2)){
     collide(ball1);
     collide(ball2);
}
If you want something unnaffected, just don't do the collision code.
Code:
if(collision(ball1, ball2)){
     collide(ball1);
}
I don't get the question...
Unless you are using some sort of premade automatic physics that can't be disabled in case of collision, in which case you are using the first case passively and I severely recommend you to make your own physics, the concept is as simple as that.
 
Top