John
John

Reputation: 307

Sphere is falling through collider when rotating the collider

I'm making a game where you rotate the ground instead of moving the ball directly. However if the ball is rolling down and I rotate the ground, the ball will fall through the collider most of the time. I set the ball's rigidbody to continuous. The ground to continuous dynamic. I tried setting them all to continuous and all to continuous dynamic. It still doesn't work. I tried playing around with the mass of the objects and nothing works. I tried using the mesh colliders and box colliders. I also tried making the ball a child of the collider I'm rotating if that matters.

I understand this can be an issue if I use transform to rotate but I'm using the rigidbody to rotate.

    [SerializeField] float upSpeed;
    [SerializeField] Rigidbody rb;
    void Update()
    {
        rb.angularVelocity = new Vector3(Input.GetAxis("Vertical") * upSpeed, 0, -Input.GetAxis("Horizontal") * upSpeed);
    }

Thanks!

Upvotes: 1

Views: 221

Answers (1)

Jukoz
Jukoz

Reputation: 117

Try to modify your ball or/and your ground collisionDetectionMode property inside of the RigidBody component to either ContinuousDynamic or Dynamic. It makes the collision detection more precise for fast gameObjects (in this case, it's the ground rotating that may be too fast). For more informations about the different collision detection methods you can find out more here.
Hopefully this helps.

Upvotes: 1

Related Questions