I’m trying to make a prototype world for my 3rd person ball rolling game, I’ve finally fixed everything and have been given the chance to work on my world building. Only after attempting to make a spinning object as a test obstacle with an extremely simple transform.Rotate script, do I find that my collision physics don’t seem to work with a moving object. I’ve looked around and can’t find a fix.
Here’s a video showing what happens:
What kind of result are you expecting? It seems there is some kind of interaction between the ball and spinning object which suggests the physics engine is working correctly, however, there might be some additional things to consider.
_
- Are you directly modifying the rigidbody’s velocity? You should not do this as it can result in unrealistic physics simulations.
_ - Discrete means Continuous Collision Detection is turned off for that RigidBody. What does that mean? Collisions for this collider will only be checked at the content’s Time.fixedDeltaTime.
_
Unity - Manual: Continuous collision detection (CCD)
_
have you tried testing with other types of collision detection?
To make it work well, you should move your character by physics, and make the obs tacle moving by physics, too. if you just rotate the obstacle transform, his body never get the acceleration. it is just like if it was “teleported” with a new rotation.
(there is way to play and animation using the physiques too)
Even others have already mentions it in comments to other answers, I want to stress it as a seperate answer: Any moving object has to have a rigidbody component if you intend to have any sort of interactions with that object. Objects that are driven by your script should have a kinematic rigidbody. Kinematic rigidbodies are not affected by other objects but can affect non-kinematic objects.
A much more general rule: Never move or rotate a collider without being part of a rigidbody. Also keep in mind that rigidbody physics is about simulating rigid bodies. That means if a rigidbody consists of several child colliders, those child colliders should never move relative to each other. They should be rigid. Only the rigidbody object as a whole (the gameobject with the rigidbody component) should move / rotate.