Car wheel rotation problem

Hi everyone, when i push the accelerate button in my race game, which my car is based on this http://java.cms.livjm.ac.uk/wiki/index.php/JME_Physics_Car, its wheels rotate incorrect like this:



when the correct is rotate through its own axis like this:





I’ve tried the z axis but i think i have understood wrong. Does anyone knows how do i fix that?



Thanks.

I beleive the problem you are experiencing is related to the joints and where they are connected. I dont have source or example in front of me, so I'm probably not much help. Maybe your anchor points are incorrect? (Struggling for words here

Yep, sounds like wrong anchor point

Thank you all, it was the anchor but i can fix it, the current value for

j.setAnchor(capsule.getLocalTranslation().subtract(anchor.getLocalTranslation()));


is Vector3F(0,0,2).  If i change to (0,0,10) or (0,0,-10) it remains the same. If i change to (0,2,0) or (2,0,0) it gets even worse. I don't really understand this rotation. Does anyone can explain it?

p.s.: again, my code is the same as http://java.cms.livjm.ac.uk/wiki/index.php/JME_Physics_Car, the difference is the 3d models that i load.

Thanks again.

Did the code work with the original models before you changed to your own?

Another question… Does the car seem to drive correct, just the wheels go all over the place and through the ground and such? If this is the case, then the problem is not with your joints, but rather your wheel models in relation to the physical wheel object. See what I'm saying? But if the car kinda hops around and your wheel models don't disappear underground, then it probably is a joint issue. Good luck.

You were right, the error was the wheel model, i fixed it and it is correct now.

Thanks a lot!

:smiley:

OK, I didn

Nice, if you could show the new code i'd like a lot.

Thanks.

Hi again, i am stuck with a car position problem. If i change the car position by its chassis like

chassis.setLocalTranslation(newPosition); //or this.setLocalTr…

only the chassis change, the wheels stay on previous position. Is there a way i can treat the car as a one?

Thanks.

You could put all the physics nodes into one scene node, but I would not recommend that. Move all physics nodes separately and manage them in a game specific class (game entity).

I was setting the position by a method in Car like i posted. Now i pass the position in constructor and it works fine.  :smiley:

Thanks.

If you wnat to change the position of the car during simulation, you'll have to detach all joints (remove the nodes from them), move the nodes, and the reattach them.

uh, why's that? It's not enough to move the nodes? That's not very nice :frowning:

I was talking about teletransport!



Normal move works fine yes… Actually, the car example works by setting joint velocities.

perick said:

I was talking about teletransport!

sure, I meant it's a pity that you need to reattach the joints (but I'm not sure if this can this can be fixed).