Game Development Community

GetLinearVelocity is broken

by Azmodeus · in Torque Game Builder · 09/26/2006 (8:53 pm) · 7 replies

If I setLinearVelocity my player moves. All fine and dandy.

However, if I hit a wall, my player stops. Still all fine and dandy, except for getLinearVelocity still returns that the player is happily moving along.

Velocity is change in distance over time. I hit a wall, i'm not moving. My velocity is 0.

So I suggest changing the API to be get/setLinearForce (which would remain constant) and fix get/setLinearVelocity to be true to the definition of velocity.



As a work around, I'm having to constantly get my current positiion and calculate its "velocity" based on its position change over time.

#1
09/26/2006 (9:17 pm)
Actually, the "LinearVelocity" is what is set as a value, not a measurement of the object's current physics state. Even though you are currently colliding with something, the object is still set to have that linear velocity (unless the collision mode you use kills off the velocity setting).

The main reason for this is something like having the ability to have a moving wall...collide with it until it moves away, then keep on going the way you want.

I admit that the name of the helper method probably could be a bit better, but that is what it's checking--the value of the variables, not measuring a position delta over time.
#2
09/26/2006 (9:42 pm)
So basically then just the dox needs to be updated to say it returns the variable, not the actual velocity.

Its still confusing. lol.
#3
09/26/2006 (10:22 pm)
Bug Issue Added: 0002221

It's in the machine, now!
#4
09/26/2006 (11:50 pm)
Bug issue? Is there a place to view current bugs?
#5
09/27/2006 (12:16 am)
That would explain the "slide up the wall" problem with the platformer tutorial and why setting Linear Velocity X to 0 in that case fixed it.
#6
09/27/2006 (8:51 am)
Quote:Bug issue? Is there a place to view current bugs?

I'm interning at GG and have been working on the docs some, so I reported it in the internal tracker.

I think there might be an external tracker somewhere, but I have no idea where it is.

Definitely a weird issue - non-intuitive indeed.
#7
09/27/2006 (9:50 pm)
I agree. Personally, I would expect setLinearVelocity to set a variable and let the player move. Then on a colision where the player is stopped andhis velocity turns to 0 that the internal state is updated to reflect that the player is no longer moving.

If the logic required that the player keep a force against the wall they should use a different function. IMO.