forked from LeenkxTeam/LNXSDK
32 lines
705 B
Haxe
32 lines
705 B
Haxe
package leenkx.logicnode;
|
|
|
|
import iron.object.Object;
|
|
import iron.math.Vec4;
|
|
import leenkx.trait.physics.RigidBody;
|
|
|
|
using leenkx.object.TransformExtension;
|
|
|
|
class ApplyTorqueImpulseNode extends LogicNode {
|
|
|
|
public function new(tree: LogicTree) {
|
|
super(tree);
|
|
}
|
|
|
|
override function run(from: Int) {
|
|
var object: Object = inputs[1].get();
|
|
var torque: Vec4 = inputs[2].get();
|
|
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
|
|
|
if (object == null || torque == null) return;
|
|
|
|
#if lnx_physics
|
|
var rb: RigidBody = object.getTrait(RigidBody);
|
|
|
|
!local ? rb.applyTorqueImpulse(torque) : rb.applyTorqueImpulse(object.transform.worldVecToOrientation(torque));
|
|
#end
|
|
|
|
runOutput(0);
|
|
}
|
|
|
|
}
|