- Home /
Duplicate Question: http://answers.unity3d.com/questions/131465/inconsistent-collision-detection.html
Simple colliding objects are updated a frame late.
Super weird but simple issue. When I drop a sphere onto a cube after applying a small amount of up force to it, it then passes through it for one frame before snapping back to where it should have stopped. How can I stop this from happening.
Steps to recreate. Using all default physics/component settings. Note, you may have to change the amount of up force. After reloading the project collision was working properly, but then changing the force bugged it again.
1) Create a cube for the ground
2) Create a sphere with a rigidbody component, place 1 or 2 meters above and attach this script.
3) Click play and go frame by frame.
public class CharacterControllerLogic : MonoBehaviour {
public Rigidbody rb;
private bool fired = false;
void Start () {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate () {
if (!fired)
{
rb.AddForce(transform.up * 350);
}
fired = true;
}
}
Passes through the ground.
Snaps back to where it should be on the next frame
Follow this Question
Related Questions
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers
Is it okay to use ForceMode.VelocityChange in Update()? 1 Answer
Get result (force & torque) of AddForceAtPosition? 2 Answers
How to get Satisfying Collision Physics 1 Answer
How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers