armory/Sources/armory/logicnode/SetVelocityNode.hx

34 lines
945 B
Haxe
Raw Normal View History

2017-04-08 00:34:45 +02:00
package armory.logicnode;
2017-11-20 15:16:52 +01:00
import iron.object.Object;
import iron.math.Vec4;
2017-09-30 00:32:06 +02:00
import armory.trait.physics.RigidBody;
2017-04-08 00:34:45 +02:00
2017-04-08 20:05:35 +02:00
class SetVelocityNode extends LogicNode {
2017-04-08 00:34:45 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-08 00:34:45 +02:00
super(tree);
}
2019-12-19 23:54:08 +01:00
override function run(from: Int) {
var object: Object = inputs[1].get();
var linear: Vec4 = inputs[2].get();
var linearFactor: Vec4 = inputs[3].get();
var angular: Vec4 = inputs[4].get();
var angularFactor: Vec4 = inputs[5].get();
2018-06-14 14:52:05 +02:00
if (object == null || linear == null || linearFactor == null || angular == null || angularFactor == null) return;
2017-04-08 00:34:45 +02:00
#if arm_physics
2019-12-19 23:54:08 +01:00
var rb: RigidBody = object.getTrait(RigidBody);
2017-04-08 00:34:45 +02:00
rb.activate();
rb.setLinearVelocity(linear.x, linear.y, linear.z);
rb.setLinearFactor(linearFactor.x, linearFactor.y, linearFactor.z);
rb.setAngularVelocity(angular.x, angular.y, angular.z);
rb.setAngularFactor(angularFactor.x, angularFactor.y, angularFactor.z);
#end
2018-10-22 10:10:33 +02:00
runOutput(0);
2017-04-08 00:34:45 +02:00
}
}