forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
31
leenkx/Sources/leenkx/logicnode/ApplyImpulseNode.hx
Normal file
31
leenkx/Sources/leenkx/logicnode/ApplyImpulseNode.hx
Normal file
@ -0,0 +1,31 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import iron.math.Vec4;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
using leenkx.object.TransformExtension;
|
||||
|
||||
class ApplyImpulseNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var object: Object = inputs[1].get();
|
||||
var impulse: Vec4 = inputs[2].get();
|
||||
var local: Bool = inputs.length > 3 ? inputs[3].get() : false;
|
||||
|
||||
if (object == null || impulse == null) return;
|
||||
|
||||
#if lnx_physics
|
||||
var rb: RigidBody = object.getTrait(RigidBody);
|
||||
|
||||
!local ? rb.applyImpulse(impulse) : rb.applyImpulse(object.transform.worldVecToOrientation(impulse));
|
||||
#end
|
||||
|
||||
runOutput(0);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user