Hey, I’m trying to rotate a model 180 degrees on the z axis before I add a RigidBodyControl to it. When I run the code the model strangely enough rotates back in its origin rotation. Could be a problem in my code, but I cant finde anything strange.
[java]//Loading the player mesh.
playerModel = new Node();
assetManager.registerLocator(“assets/”, FileLocator.class.getName());
playerModel = (Node) assetManager.loadModel(“Models/model/model.mesh.xml”);
//Animation
animControl = playerModel.getControl(AnimControl.class);
animControl.addListener(this);
channel1 = animControl.createChannel();
channel1.setAnim(“Swim”);
channel1.setLoopMode(LoopMode.Loop);
channel1.setSpeed(0.2f);
playerModel.setLocalScale(size);
//Rotate 180 degrees
Quaternion q = new Quaternion();
q.fromAngleAxis(FastMath.PI * 180 / 180, Vector3f.UNIT_Z);
playerModel.setLocalRotation(q);
playerPhysicsControl = new RigidBodyControl(new SphereCollisionShape(size));
playerModel.addControl(playerPhysicsControl);
pSpace.add(playerPhysicsControl);
playerPhysicsControl.setLinearDamping(0.2f);
//This is how the physics object is initialized. It is beeing attached to the root node on a different place in the code.
[/java]
Strange, normally the RigidBodyControl should read the location of the Spatial and set that as the physics location when the control is attached… Anyway, set the location/rotation using RigidBodyControl.setPhysicsLocation() and setPhysicsRotation(), that should work.