- Home /
How to set speed to zero
I want that when player gets teleported his speed get set to zero. Because my teleportation is in the air and when i fall i get teleported with the same speed and it gets a little glichy. P.s srr for grammar :(
public class TeleportationPad : MonoBehaviour {
public GameObject player;
public Transform spawnPoint;
void OnTriggerEnter(Collider col){
if (col.tag == "Player") {
player = col.transform.gameObject;
player.transform.position = spawnPoint.transform.position;
player.transform.rotation = spawnPoint.transform.rotation;
}
}
Comment
Best Answer
Answer by dev-waqas · Jan 19, 2018 at 12:58 PM
Here you go. Set its Rigidbody velocity to zero.
public class TeleportationPad : MonoBehaviour {
public GameObject player;
public Transform spawnPoint;
void OnTriggerEnter(Collider col){
if (col.tag == "Player") {
player = col.transform.gameObject;
player.transform.position = spawnPoint.transform.position;
player.transform.rotation = spawnPoint.transform.rotation;
player.GetComponent<Rigidbody>().velocity = Vector3.zero;
}
}