This commit is contained in:
2026-05-06 17:52:45 -07:00
parent 9fc3f35125
commit 1463c23334
402 changed files with 3758 additions and 0 deletions

View File

@ -0,0 +1,10 @@
Rigid body set to:
- Active dynamic
- Axis and rotation locked (linear and angular factor)
- Trigger/Ghost checked making this a trigger instead of a collision object
- Force deactivation unchecked to make sure physics engine keep the rigid body active
- Trigger script checks for overlapping rigid bodies on each update
## How to test
Move the box around using WASD+QE.
When box is overlapping sphere the icoshpere object is visible, otherwise it's hidden.

View File

@ -0,0 +1,40 @@
package lnx;
import iron.object.Object;
import iron.Scene;
import leenkx.trait.physics.PhysicsWorld;
import leenkx.trait.physics.RigidBody;
class Trigger extends iron.Trait {
var rb:RigidBody;
var physics:leenkx.trait.physics.PhysicsWorld;
var obj:Object;
public function new() {
super();
notifyOnInit(function() {
rb = object.getTrait(RigidBody);
physics = leenkx.trait.physics.PhysicsWorld.active;
obj = Scene.active.getChild("Icosphere");
});
notifyOnUpdate(function() {
// TODO: replace with notifyOnCollisionEnter or notifyOnTriggerEnter once implemented
// ref: https://github.com/leenkx3d/leenkx/issues/331
var rbs = physics.getContacts(object.getTrait(RigidBody));
var visible = false;
if (rbs != null) {
for (rb in rbs){
if(rb.object.name == "Cube"){
visible = true;
}
}
}
obj.visible = visible;
});
}
}