Tank Throwing Sphere
Posted: Wed Oct 28, 2009 2:24 pm
Hey guys,
Im having trouble understanding ApplyImpulse.
I have a Tank and once an enemy has been targeted, I got a sphere to be added into the space and I have applied an impulse, but it doesnt do what I want it to do.
Obviously I want the sphere to come out of the tank (lets say its at Vector3 position) and the target is at Vector3 targetPosition.
I have tried this:
but all it does is just comes out of the tank's position and then drops. Theres no impulse at all.
I also tried
But I need to know how strong to throw the ball... I have the distance.. I just need to know how to do this right if all I have is the distance.
Can anyone please help me? Much appreciate it!
Thanks!!
Im having trouble understanding ApplyImpulse.
I have a Tank and once an enemy has been targeted, I got a sphere to be added into the space and I have applied an impulse, but it doesnt do what I want it to do.
Obviously I want the sphere to come out of the tank (lets say its at Vector3 position) and the target is at Vector3 targetPosition.
I have tried this:
Code: Select all
ball.applyImpulse(Position, Vector3.Normalize(LockedTarget.Position - Position));
I also tried
Code: Select all
Vector3 direction = Vector3.Zero;
direction = LockedTarget.Position - Position;
direction.Y += (10.0f * (float)Math.Sin(45));
//ball.applyImpulse(Position, Vector3.Normalize(direction));
Can anyone please help me? Much appreciate it!
Thanks!!