I am making a racing game, and I have a checkpoint script that changes the place I spawn in when I hit my ‘Death Pit’. But when I respawn, I still have the force of my car falling, causing my car to glitch out and go through the terrain, and sometimes be launched upwards due to the previous downwards force (from when I was falling) acting on it. Is there a way to reset the force to none once I hit the Death Pit?
Here is my script so far:
using UnityEngine;
using System.Collections;
public class Respawn2 : MonoBehaviour {
private Vector3 startPos;
// Use this for initialization
void Start ()
{
startPos = transform.position;
}
//detect collision with trigger//
void OnTriggerEnter(Collider col)
{
if (col.tag == "death")
{
transform.position = startPos;
}
else if(col.tag == "checkpoint")
{
startPos = col.transform.position;
}
}
}