vehicle falls off loop (physics problem?)
Not a great title but I can't think of a good way to describe this problem, so there's a video of it here:
Basically whenever the vehicle reaches a point near the top of the loop, it falls off and sort of teleports to the ground below.
I've done some testing and can't find the cause of the problem: I rebuilt the environment in another scene and it worked fine, with the exact same code to be run on the loop:
RaycastHit hit;
Physics.Raycast(transform.position, -transform.up, out hit);
Vector3 forwardDir = Vector3.Cross(transform.right, hit.normal);
Quaternion newLook = Quaternion.LookRotation(forwardDir, hit.normal);
transform.rotation = Quaternion.Slerp(transform.rotation, newLook, 0.05f);
if (Physics.Raycast(transform.position, -hit.normal, 0.3f))
{
//rb.AddForce(hit.normal * 4, ForceMode.Acceleration);
}
else
{
//rb.AddForce(-hit.normal * 25, ForceMode.Acceleration);
}
(There is other code for the player to move while on the loop). Does anyone know why this could be happening or has anyone experienced something similar in the past?
Your answer
Follow this Question
Related Questions
X-Axis rotation quirk 0 Answers
Make camera have same rotation but with an offset 0 Answers
Saving and loading cube data 2 Answers
Why doesn't my asteroid field perfectly move with me? 1 Answer