Right now I have three different types of objects: Player (Any character), Dynamic (pushable), and Solid (does not move)
The following response causes the second object to be pushed by the first (player kicks a can out of his way)
Code: Select all
objects[j]->Center( objects[j]->Center() + normal );
Code: Select all
objects[i]->Center( objects[i]->Center() - normal );
This is what I'm playing with at the moment:
Code: Select all
for( int i = 0; i < numberOfObjects; i++ ){
    for( int j = 0; j < numberOfObjects; j++ ){
        if( AABBCollisionCheck(objects[i], object[j], normal) ){
            //PLAYER pushes DYNAMIC
            if( objects[i]->Type() == PLAYER_OBJECT && objects[j]->Type() == DYNAMIC_OBJECT ){
                objects[j]->Center( objects[j]->Center() + normal );
            //PLAYER is stopped by SOLID
            }else if(objects[i]->Type() == PLAYER_OBJECT && objects[j]->Type() == SOLID_OBJECT ){
                objects[i]->Center( objects[i]->Center() - normal );
            //DYNAMIC is pushed by PLAYER
            }else if( objects[i]->Type() == DYNAMIC_OBJECT && objects[j]->Type() == PLAYER_OBJECT ){
                objects[i]->Center( objects[i]->Center() - normal );
            //SOLID is unaffected by PLAYER
            }else if( objects[i]->Type() == SOLID_OBJECT && objects[j]->Type() == PLAYER_OBJECT ){
                objects[j]->Center( objects[j]->Center() + normal );
            }else{
                objects[i]->Center( objects[i]->Center() - normal );
                objects[j]->Center( objects[j]->Center() + normal );
            }
        }
    }
}
Â
The first way I tried to solve this was to set the dynamic object's type to solid while it was colliding with a solid, but I couldn't figure out how or when to change it back to dynamic (so it would become "stuck" as if it were a solid itself).
How would you handle collisions between objects with different properties?
Thanks for reading!