Setting velocity makes a T2DAnimatedSprite disappear
by RollerJesus · in Torque X 2D · 06/06/2010 (5:55 pm) · 4 replies
Hi all.
I'm just picking up TX2D and am having an issue that I can't seem to tackle.
When I execute the following code, I get my animated sprite doing it's thing right where I expect:
What am I missing?
Any help appreciated,
Patrick
I'm just picking up TX2D and am having an issue that I can't seem to tackle.
When I execute the following code, I get my animated sprite doing it's thing right where I expect:
public void fireShot()
{
//Get and instance of the fireBall template
_projectileTemplate = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>("projectile");
T2DSceneObject projectile = _projectileTemplate.Clone() as T2DSceneObject;
projectile.Position = SceneObject.Position;
//projectile.Physics.Velocity = new Vector2(5, 0);
TorqueObjectDatabase.Instance.Register(projectile);
...
}However, when I uncomment the line that sets the objects physics, I don't see it move; it's just gone.What am I missing?
Any help appreciated,
Patrick
#2
Physics component is on the object.
World limit is set and it's outside the viewing area. Tried with and without it as well.
Template is checked and the compiler hits a breakpoint at all those lines - even shows a correct velocity value in the watch window.
I just created a t2dStaticSprite in the editor, set it's X Velocity to 5 and it never shows in the scene but without the velocity it shows fine.
06/06/2010 (8:21 pm)
Thanks for responding Henry.Physics component is on the object.
World limit is set and it's outside the viewing area. Tried with and without it as well.
Template is checked and the compiler hits a breakpoint at all those lines - even shows a correct velocity value in the watch window.
I just created a t2dStaticSprite in the editor, set it's X Velocity to 5 and it never shows in the scene but without the velocity it shows fine.
#3
Either that or set the object type of the bullet and in the T2DCollisionComponent rollout set the type it collides with.
06/06/2010 (11:00 pm)
Did you try unchecking Collision Enabled under Scene Object in the tx2d editor? Is this appearing on top of a background image? I have had issues where my bullets collided with either the gun or a background element.Either that or set the object type of the bullet and in the T2DCollisionComponent rollout set the type it collides with.
#4
That was it! I should have been able to get that one on my own. Thank you so much!
Say it with me now... Rook-ie! Rook-ie! Rook-ie!
Patrick
06/07/2010 (6:05 am)
Henry,That was it! I should have been able to get that one on my own. Thank you so much!
Say it with me now... Rook-ie! Rook-ie! Rook-ie!
Patrick
Torque 3D Owner Henry Shilling
Smokin Skull
Here is how I do it, it's basically the same as you:
if (_projectile != null) { T2DSceneObject projectile = _projectile.Clone() as T2DSceneObject; projectile.Rotation = SceneObject.Rotation; projectile.Position = SceneObject.Position; projectile.Physics.Velocity = T2DVectorUtil.VectorFromAngle(SceneObject.Rotation) * _projectileSpeed; TorqueObjectDatabase.Instance.Register(projectile); }