ApplyImpulse in TX or schedule function
by Vincenzo Selvaggio · in Torque X 2D · 06/24/2007 (1:16 pm) · 2 replies
Hi All,
I'd like to apply an impulse to an object, I tried:
ourObject.Physics.ApplyImpulse(new Microsoft.Xna.Framework.Vector2(0.0f, -1.0f));
It works but the object keeps moving without stopping (different from TGE applyImpulse on a non static obj).
Should I set any physic parameters?
Alternatively I was thinking to create a schedule (like in TGE), so after let's say 1s I'll change the velocity of the object back to the vector (0,0) to stop it. The issue is that I can't find such a function, can I do it in another way?
Thank you very much,
Vincenzo
I'd like to apply an impulse to an object, I tried:
ourObject.Physics.ApplyImpulse(new Microsoft.Xna.Framework.Vector2(0.0f, -1.0f));
It works but the object keeps moving without stopping (different from TGE applyImpulse on a non static obj).
Should I set any physic parameters?
Alternatively I was thinking to create a schedule (like in TGE), so after let's say 1s I'll change the velocity of the object back to the vector (0,0) to stop it. The issue is that I can't find such a function, can I do it in another way?
Thank you very much,
Vincenzo
About the author
#2
it worked great!!!
public void stopSemiMobWall(object sender, ScheduledEventArguments args)
{
T2DSceneObject wallSemiMob = (T2DSceneObject)args.DataToSend;
wallSemiMob.Physics.Velocity = new Microsoft.Xna.Framework.Vector2(0.0f, 0.0f);
}
See you,
Vincenzo
06/24/2007 (4:04 pm)
Thank you Josh,it worked great!!!
public void stopSemiMobWall(object sender, ScheduledEventArguments args)
{
T2DSceneObject wallSemiMob = (T2DSceneObject)args.DataToSend;
wallSemiMob.Physics.Velocity = new Microsoft.Xna.Framework.Vector2(0.0f, 0.0f);
}
See you,
Vincenzo
Torque Owner Josh Butterworth
TorqueEngineComponent.Instance.GameTimeSchedule.Schedule(2000, SpawnCallback);
There's an overload that lets you pass an object in which case your callback would look something like:
public void SpawnCallback(object sender, ScheduledEventArguments args)
{
T2DSceneObject toSpawn = (T2DSceneObject)args.DataToSend;
//do something here
}
I havent touched the impulse stuff so sorry cant help you there.