Game Development Community

Does getLinearVelocityY() work on a mounted object?

by Conor O Kane · in Torque Game Builder · 04/07/2007 (10:17 am) · 3 replies

I'm trying to get the vertical velocity of my player so that I can adjust its graphic based on the speed. However I'm controlling it by mounting it to another object. When I call getLinearVelocityY() on my player object it always returns 0. Is this because I'm using the mounting force instead of setLinearVelocity to move it? Is there any way to get the Y velocity of an object that's mounted?

#1
04/08/2007 (12:42 am)
Well I just wrote my own function to find the player's Y speed, by passing itself the previous Y position and checking every 100 miliseconds.

It works pretty well, the banking animation matches the speed, but occasionally it jitters a little, when the speed is right on the boundary between 2 animation frames :-(

I guess I need to figure out a way to 'smooth' the speed changes to avoid the jittering?
#2
04/08/2007 (12:21 pm)
Conor, why not just grab the velocity of the object the player is mounted too?
#3
04/08/2007 (9:13 pm)
I solved this problem by just doubling the amount of frames in the animation.

My control system has the joystick driving an invisible 'target' around the scene and the player's ship smoothly following this with a low mount force. This makes for very smooth motion with a sense of momentum - so it was important that the player graphic relate closely to its own speed and not the target. Fortunately my ship is a 3d model rendered to sprites, so it was a simple task to just add more frames to smooth out the banking.

There is still a slight jitter on frame boundries, but because the animation frames are closer together it's not too jarring.