- Home /
Friction issue with rotating sphere
My game involves a ship landing on a rotating spherical planet. The planet is a simple spherical object with a sphere collider and a kinematic rigidbody. It also has a gravity field script applying an attraction force to nearby rigid bodies, excluding itself, of course.
My issue arises when the ship, a triangular mesh with corresponding mesh collider and non-kinematic rigid body, lands. It doesn't rotate along with the planet, even if both physics materials have a friction of one.
Now, the planet, being kinematic, is rotated each frame using transform.Rotate(). Is it possible that doing so bypasses the physics simulation?
Is it also possible that the constant force being applied towards the center of the planet is screwing with the friction mechanics? I doubt so, because it's basically the same as using the built-in gravity feature: constant force applied in a constant direction.
I'm pretty sure that the physics setup is fine because the ship properly sticks to and slides along a plane.
Anyway, those are the theories I came up with, but right off the bat I'm not sure how I could test them. Maybe it's something else, too.
Thanks!
Nope, I disabled gravity after a collision, and I have the same behavior.
And yep, if I set the planet's rigidbody as non-kinematic and rotate them with angular velocity ins$$anonymous$$d, the ship does frictate properly. To frictate is a real word, isn't it? Anyways. Can anyone think of a way to make friction work with Rotate() ? I'm kind of worried that something could bump and move a planet even if I gave them a large mass.
Answer by Meater6 · May 25, 2011 at 08:56 PM
transform.rotate does not use physics engine, it just changes the transform component. A few things to try:
Make the collider a separate object
Add torque instead of rotation
It would be helpful if you would give the script in a edit to your question.
I hope this helps
Well there isn't much code involved, really. Just a transform.Rotate(whatever) in Update(). And the gravity is irrelevant.
Also, adding torque means that I make the planet a non-kinematic rigidbody, which I'd prefer to avoid. I'll look into your first suggestion though. It might actually work!
Yes, I see your point. For if it is non-kinematic then its rotation can be sped up or slowed if there was a car driving on it. $$anonymous$$aybe set the angular velocity to a constant vector? If you lock the planet's position it might work.
Setting the angular velocity does work, but again, it has to be a non-kinematic rigidbody.
But I could indeed lock the planet's all three axes. That would work too. And ins$$anonymous$$d of setting the rotation directly, my script could just make sure that the angular velocity stays constant by overwriting it every frame. Yup I think I'll do that.
Sweet!