Improve Set Activation node

This commit is contained in:
knowledgenude 2020-09-06 15:11:22 -03:00 committed by GitHub
parent 193c712bf4
commit 974ad7cb36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,15 +4,15 @@ import iron.object.Object;
import armory.trait.physics.RigidBody;
/**
define ACTIVE_TAG 1
define ISLAND_SLEEPING 2
define WANTS_DEACTIVATION 3
define DISABLE_DEACTIVATION 4
define DISABLE_SIMULATION 5
**/
class SetActivationStateNode extends LogicNode {
public var property0: String;
public var state: Int;
public function new(tree: LogicTree) {
super(tree);
}
@ -21,11 +21,23 @@ class SetActivationStateNode extends LogicNode {
var object: Object = inputs[1].get();
if (object == null) return;
var state: Int = inputs[2].get();
#if arm_physics
var rigidBody = object.getTrait(RigidBody);
if (rigidBody != null && state > 0 && state < 5) rigidBody.setActivationState(state);
if (rigidBody == null) return;
switch (property0) {
case "Inactive":
state = 0; // Inactive Tag
case "Active":
state = 1; // Active Tag
case "Always Active":
state = 4 ; // Disable Deactivation
case "Always Inactive":
state = 5; // Disable Simulation
}
rigidBody.setActivationState(state);
#end
runOutput(0);