Vehicle scale problems

Hi,



I just implemented doors to change levels in my game. When you click on a door, the current level is replaced by the one the door leads too. Changing the levels works good, but the vehicle and it’s wheels, which are in the second level, are scaled down every time the second level is loaded. The vehicle still keeps working.



I recorded the bug so you can see what happens.

http://youtu.be/hvelZawsWFk



This is the code that gets executed when going to the second level:

[java]this.rootNode.detachAllChildren();

this.bulletAppState.getPhysicsSpace().remove(this.ln);

this.ln.removeControl(RigidBodyControl.class);

this.ln = ((Node)this.assetManager.loadModel(“Models/wereld/Mars-2179/winkel/Plane.j3o”));

this.ln.scale(8.0F);

this.rootNode.attachChild(this.ln);

this.ln.addControl(new RigidBodyControl(0.0F));

this.bulletAppState.getPhysicsSpace().add(this.ln);

this.player.setPhysicsLocation(new Vector3f(-2.0F, 10.0F, 2.0F));[/java]



And this is the code that gets executed when going back to the first level:

[java]this.rootNode.detachAllChildren();

this.bulletAppState.getPhysicsSpace().remove(this.ln);

this.ln.removeControl(RigidBodyControl.class);

this.ln = ((Node)this.assetManager.loadModel(“Models/wereld/Mars-2179/Aula.j3o”));

this.ln.scale(10.0F);

this.rootNode.attachChild(this.ln);

this.ln.addControl(new RigidBodyControl(0.0F));

this.bulletAppState.getPhysicsSpace().add(this.ln);

player.setPhysicsLocation(new Vector3f(20F, 5F, -18F));[/java]



What am I doing wrong?



many thanks in advance.

use “setLocalScale” instead of “scale”

1 Like

Thank you