Update Files
This commit is contained in:
26
leenkx/Sources/leenkx/logicnode/HasContactNode.hx
Normal file
26
leenkx/Sources/leenkx/logicnode/HasContactNode.hx
Normal file
@ -0,0 +1,26 @@
|
||||
package leenkx.logicnode;
|
||||
|
||||
import iron.object.Object;
|
||||
import leenkx.trait.physics.RigidBody;
|
||||
|
||||
class HasContactNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function get(from: Int): Dynamic {
|
||||
var object1: Object = inputs[0].get();
|
||||
var object2: Object = inputs[1].get();
|
||||
|
||||
if (object1 == null || object2 == null) return false;
|
||||
|
||||
#if lnx_physics
|
||||
var physics = leenkx.trait.physics.PhysicsWorld.active;
|
||||
var rb2 = object2.getTrait(RigidBody);
|
||||
var rbs = physics.getContacts(object1.getTrait(RigidBody));
|
||||
if (rbs != null) for (rb in rbs) if (rb == rb2) return true;
|
||||
#end
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user