I noticed when I rotate the object attached to my player control that the physics always set it’s rotation angles to 0. Is there a way to rotate the control itself ? (JME 3.0)
If the object is a RigidBodyControl.
No , it’s a spatial with an attached BetterCharacterControl. My rotation code works on other spatials in my scene but has no effect on the spatial with the BetterCharacterControl attached. The control itself only has a set direction/velocity function but nothing to control rotation. I’m just curious is this is a bug or something that was over looked.
You can extend BetterCharacterControl to access .setPhysicsRotation directly but that might not work when BCC updates it in its controlUpdate.
Quaternion q = desiredRotation; Vector3f vViewDirection = q.mult(Vector3f.UNIT_Z); ctrl.setViewDirection(vViewDirection);
This should work, atleast for the Yaw (I guess), like the way you actually look.
Note: Its always better to simply have a viewDirection^^
Thanks , I overlooked the viewDirection. I seen the Vector3f and assumed it was for something else. I made a turn by doing.
Quaternion turn = new Quaternion(); turn.fromAngles(0, 90, 0); Vector3f vViewDirection = turn.mult(Vector3f.UNIT_Z); /* The rotation is applied: The object rolls by 180 degrees. */ scene.physicsLogic.playerControl.setViewDirection(vViewDirection);
The only thing I’ll need is a variable to keep track of the angle and I’m good to go.
Thanks a million.
@Darkchaos Okay , I’ve ran into a weird issue. Using the setViewDirection for rotation works fine until I detach and object from the rootNode. After removing an object for example I pick up a powerup and remove it from the root node the rotation goes nuts and starts spinning at super sonic speeds. Have you heard of this issue before ?
Nope. The Powerup isn’t connected to your BCC?
For the speed simply print out how you change your rotation.
I guess you don’t use tpf and so your Framerate goes up when detatching the spatial
I used tpf and it doesn’t just go up it goes to light speed. I’ll make a small sample tomorrow when I get some free time to show you what is happening.
Angles should be in radians.