- Home /
Collisions not working with rotating objects
To better show my problem i have made a video here.
I’m working on a 3D platformer, and I am trying to make rotating platforms but I’m having trouble with weird collisions. As seen in the video the player does not seem to collide with the moving objects at all when standing right in the movement direction. The setup is an empty game object with a script attached that rotates it along an axis. That empty
object has child objects for the platforms.
I have tried different things:
- Rotating the empty parent in Update and FixedUpdate
- Mesh colliders and primitive colliders for the platforms
- Rotating the parent with transform.Rotate
- Adding a rigidbody to the empty parent and rotating it with rigidbody.MoveRotation
- Adding a rigidbody to the empty parent and rotating it with rigidbody.AddTorque
- Add rigidbodies to the platforms
- Changing the collision detection on the player and the platforms and the empty parent
The player movement is done with a rigidbody so to see if anything is wrong whit the player, I added a cube with a box collider and a rigidbody and it behaves almost the same way.
The code to rotate the empty parent is this. But as i said i tried different things.
public class SimpleRotate : MonoBehaviour
{
public Vector3 rotateSpeed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
rb.AddTorque((rotateSpeed - rb.angularVelocity) * Time.fixedDeltaTime, ForceMode.VelocityChange);
}
}
Does anyone know what the problem could be?