I am making a game in which I want the player be able to grapple with its car and slip around the object for as long as the car is attached. Basically rotating around and object with physics
With setting the rigidbodies angular velocity, I got a result I want to achieve, although this is not working for me because it flies of in the air every now and then… At the bottom of this post, you can see what I mean with that.
Anyway, what I want to ask if I can get a likewise (but better) effect like this, but with wheel colliders?
After searching for some time and some adjusting, I found a solution.
Basically what I needed was this snippet of code:
Quaternion q = Quaternion.AngleAxis(radius * currentSpeed, Vector3.up);
rb.MovePosition(q * (rb.transform.position - fixedGrapplePoint) + fixedGrapplePoint);
rb.MoveRotation(rb.transform.rotation * q);
With this I was able to keep using physics as I described in my question.
One thing to note is that the center of mass of the rigidbody should be on the car and that the axis is in world space. Not having that in world space also gave me weird effects…
Anyway, it is fixed now!
Here is a link to the source: Transform.RotateAround with Rigidbody and Physics