Fix physics constraints at start-up

This commit is contained in:
QuantumCoderQC 2020-12-17 15:01:21 +01:00
parent 882dea8d6c
commit bf22d7add6
2 changed files with 7 additions and 2 deletions

View file

@ -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() {

View file

@ -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();
}
}