I have a simple box car with a rigidbody, collider, and Collision Detection set to Continuous Dynamic. When I freeze y position to stop the car from flipping, any contact with a wall will make the car slide like its on ice until I turn off freeze y position.
Is there anyway to stop this behavior or another way to lock a rigidbody from flipping?
private void Update()
{
moveInput = Input.GetAxis("Vertical");
rotationInput = Input.GetAxis("Horizontal");
}
private void FixedUpdate()
{
MoveTankObj(moveInput);
RotatateTank(rotationInput);
}
void MoveTankObj(float input)
{
Vector3 moveDirection = transform.forward * input * moveSpeed * Time.fixedDeltaTime;
rb.MovePosition(rb.position + moveDirection);
}
void RotatateTank(float input)
{
float roation = input * rotationSpeed * Time.fixedDeltaTime;
Quaternion turnRotation = Quaternion.Euler(0, roation, 0);
rb.MoveRotation(rb.rotation * turnRotation);
}