Game Development Community

Help with locked door

by Arthur Yanthar · in Torque X 2D · 11/06/2009 (11:29 am) · 1 replies

For my level, you will need to get a key to open a locked door. What I did so far is that there will be a kill collision for the key when the player collides it, and that the level will end when the player collides with the door. I also know that you should make a boolean called like hasKey which will be true when the player collides with the key, and that is has to be true in order to end a level. However there is one thing I need help with. How could I check if the key has been "killed" in order to turn on the on the boolean? Thanks in advanced!

#1
11/06/2009 (8:08 pm)
Make a custom collision delegate that sets the boolean and then calls the kill collision.
public static void KeyCollide(T2DSceneObject ourObject, T2DSceneObject theirObject, ref T2DCollisionInfo info, T2DCollisionMaterial physicsMaterial, bool handleBoth)
{
    T2DPhysicsComponent.KillCollision(ourObject, theirObject, ref info, physicsMaterial, false);
    Player.HasKey = true;
}
Something like that. Youd have to do checks to make sure ourObject is the key and theirObject is the player, or just make sure this delegate is only used for the key and all it can collide with is the player to use it.