2018-04-13 07:05:54 +02:00
|
|
|
package armory.logicnode;
|
|
|
|
|
|
|
|
import iron.object.Object;
|
|
|
|
import armory.trait.physics.RigidBody;
|
|
|
|
|
2020-11-02 15:51:34 +01:00
|
|
|
using armory.object.TransformExtension;
|
|
|
|
|
2018-04-13 07:05:54 +02:00
|
|
|
class GetVelocityNode extends LogicNode {
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
public function new(tree: LogicTree) {
|
2018-04-13 07:05:54 +02:00
|
|
|
super(tree);
|
|
|
|
}
|
|
|
|
|
2019-12-19 23:54:08 +01:00
|
|
|
override function get(from: Int): Dynamic {
|
|
|
|
var object: Object = inputs[0].get();
|
2020-11-02 16:55:11 +01:00
|
|
|
var localLinear: Bool = inputs.length > 1 ? inputs[1].get() : false;
|
|
|
|
var localAngular: Bool = inputs.length > 2 ? inputs[2].get() : false;
|
2020-11-02 15:51:34 +01:00
|
|
|
|
2018-04-13 07:05:54 +02:00
|
|
|
if (object == null) return null;
|
|
|
|
|
|
|
|
#if arm_physics
|
2019-12-19 23:54:08 +01:00
|
|
|
var rb: RigidBody = object.getTrait(RigidBody);
|
2018-04-13 07:05:54 +02:00
|
|
|
|
2020-11-02 15:51:34 +01:00
|
|
|
if (from == 0) {
|
|
|
|
!localLinear ? return rb.getLinearVelocity() : return object.transform.worldVecToOrientation(rb.getLinearVelocity());
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
!localAngular ? return rb.getAngularVelocity() : return object.transform.worldVecToOrientation(rb.getAngularVelocity());
|
2018-04-13 07:05:54 +02:00
|
|
|
}
|
|
|
|
#end
|
2020-11-02 15:51:34 +01:00
|
|
|
|
2020-10-02 00:16:22 +02:00
|
|
|
return null;
|
2018-04-13 07:05:54 +02:00
|
|
|
}
|
2020-11-02 15:51:34 +01:00
|
|
|
|
2018-04-13 07:05:54 +02:00
|
|
|
}
|