Getting a player/vehicle/tank direction
by Mark Berry · in Torque Game Engine · 12/01/2005 (4:07 pm) · 4 replies
How do I get a vector describing the direction an object is moving in? I can get its transform/forwardvector etc, but if an object is skidding etc, what then?
I'm looking to implement this in a StaticShape's onCollision method, to get the direction of collision impact. I would like to keep this in script too atm, as I'm not terribly confident of modding the engine itself for this.
Basically I'm trying to trigger a scripted fall of an object when struck. The rigid shape class, while doing most of this, is more suited to a game of skittles, and adds overhead apparently, so using it for trees/signs etc is out.
Cheers, Mark.
I'm looking to implement this in a StaticShape's onCollision method, to get the direction of collision impact. I would like to keep this in script too atm, as I'm not terribly confident of modding the engine itself for this.
Basically I'm trying to trigger a scripted fall of an object when struck. The rigid shape class, while doing most of this, is more suited to a game of skittles, and adds overhead apparently, so using it for trees/signs etc is out.
Cheers, Mark.
#2
12/01/2005 (4:59 pm)
I believe that getvelocity() returns how fast you are moving in each direction it might look like 25 25 0 if you were moving diagonal or skidding diagonally
#3
12/01/2005 (5:03 pm)
Youou can't really do that properley from script without 1.4, since there's no way to move an object around in script without having the tick exposed (1.4 has this). And the rigid shape class doesn't really add a lot of overhead with the proper implementation where it doesn't do any updates when idle. Anyways, to get the collision angle, you would check the difference between the point of collision and the center of the object you hit for a good vector to knock it along. Though I guess working in the velocity may be good for some types of calculations as well for impacts.
#4
plain old 1.3 has %object.setTransform() and %object.setVelocity(),
which are pretty useful for moving things around from script...
12/01/2005 (5:35 pm)
Quote:
You can't really do that properley from script without 1.4, since there's no way to move an object around in script without having the tick exposed (1.4 has this).
plain old 1.3 has %object.setTransform() and %object.setVelocity(),
which are pretty useful for moving things around from script...
Torque Owner Cinder Games