Fix physics constraints at start-up
This commit is contained in:
parent
882dea8d6c
commit
bf22d7add6
|
@ -73,7 +73,7 @@ class PhysicsConstraint extends iron.Trait {
|
|||
if(limits == null) limits = [for(i in 0...36) 0];
|
||||
this.limits = limits;
|
||||
|
||||
notifyOnAdd(init);
|
||||
notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
|
|
@ -17,6 +17,7 @@ class PhysicsConstraintExportHelper extends iron.Trait {
|
|||
var disableCollisions: Bool;
|
||||
var breakingThreshold: Float;
|
||||
var limits: Array<Float>;
|
||||
var constraintAdded: Bool = false;
|
||||
|
||||
public function new(body1: String, body2: String, type: Int, disableCollisions: Bool, breakingThreshold: Float, limits: Array<Float> = null) {
|
||||
super();
|
||||
|
@ -34,7 +35,11 @@ class PhysicsConstraintExportHelper extends iron.Trait {
|
|||
var target1 = Scene.active.getChild(body1);
|
||||
var target2 = Scene.active.getChild(body2);
|
||||
object.addTrait(new PhysicsConstraint(target1, target2, type, disableCollisions, breakingThreshold, limits));
|
||||
this.remove();
|
||||
constraintAdded = true;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(constraintAdded) this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue