Player immediately moves down off the screen when mounting to another object on collision
by Randy Lutcavich · in Torque X 2D · 08/28/2009 (12:27 pm) · 7 replies
If I mount an theirObject to ourObject when they collide, ourObject (the player) immediately starts to move down and eventually is completely off the screen.
public static void MountOnCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
{
theirObject.Mount(ourObject, "LinkPoint1", false);
}About the author
Recent Threads
#2
Make sure to re-enable collisions when it gets dismounted though.
08/29/2009 (1:57 am)
I've had that problem as well. Chris has it right (as far as my problem went). Try: 1. public static void MountOnCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
{
theirObject.Mount(ourObject, "LinkPoint1", false);
theirObject.CollisionsEnabled = false;
}Make sure to re-enable collisions when it gets dismounted though.
#3
Since I want theirObject to still collide with enemy bullets I need to find a way to have collision enabled but not have theirObject collide with ourObject.
Do you guys know the code for removing an object type from the object's CollideWith field?
I though it would be something like the following but this doesn't work:
08/29/2009 (2:43 am)
Ah, that is the problem. Thanks guys.Since I want theirObject to still collide with enemy bullets I need to find a way to have collision enabled but not have theirObject collide with ourObject.
Do you guys know the code for removing an object type from the object's CollideWith field?
I though it would be something like the following but this doesn't work:
theirObject.Collision.CollidesWith.GetType(player) = false;
#4
Course you could always just reset the CollidesWith like(honestly, Id do it like this):
08/29/2009 (4:11 am)
I'm pretty sure it's like this(MAKE SURE ITS COLLIDING WITH THE PLAYER FIRST):theirObject.Collision.CollidesWith -= TorqueObjectDatabase.Instance.GetObjectType("player");Course you could always just reset the CollidesWith like(honestly, Id do it like this):
theirObject.Collision.CollidesWith = TorqueObjectDatabase.Instance.GetObjectType("bullet")+TorqueObjectDatabase.Instance.GetObjectType("Whatever");
#5
What do you mean by "reset the collideswith"? Does that happen when I disable the collision and then re-enable it?
08/30/2009 (6:44 am)
Thanks. The method you suggested for removing the object type does not seem to work. That would be really helpful if it did though.What do you mean by "reset the collideswith"? Does that happen when I disable the collision and then re-enable it?
#6
08/30/2009 (2:51 pm)
just meant you change it totally by setting it again. I wasnt sure the minus one was going to work, but didn't really want to try it myself, but the = whatever you want it to collide with afterwards does work.
#7
08/30/2009 (2:55 pm)
Ah gotcha. I was actually setting the original collidesWith in TXB but maybe I'll try doing it all in code. I still need to know how to remove an object type though.
Torque Owner Christopher Perkins
It might be a weird bug from you constantly mounting it every tick.