- Home /
Spinning rigidbody platform in 2D
I've been trying to find a way to make a rotating platform for my 2D game that has a fixed rotation speed, uses Unity's built-in physics system (so collisions are smooth) and doesn't react to other rigidbodies colliding against it (so it'd always have the same angular velocity.
First, I tried using a kinematic rigidbody and a script that changed the platform's rotation on the Update event, but that made for some clunky collision checking (the player could go through platforms if they were large or thin enough). My latest attempt consisted a non-kinematic rigidbody with the following C# script attached to it:
public Vector3 rotation = Vector3.zero;
private void Awake() {
rigidbody.angularVelocity = rotation;
}
This made for a rotating object that used Unity's built-in physics like I wanted, but upon testing it, I found out the platform's rotation speed and direction changed when the player or some other rigidbody collided against it.
A solution I tried was giving the rotating platform really high mass to minimize changes from collisions, but I'm guessing there's a better way to do that.
Your answer
Follow this Question
Related Questions
Need help with a relatively simple issue. 1 Answer
2D floating object 2 Answers
rigidbody2D.addforce in collider 1 Answer
AddForce with 2D Character 2 Answers
Object jumps right after the attached HingeJoint2D is Enabled 0 Answers