Stop moving Ball after respawn for seconds c#
Hey!
Im trying to get a ball to respawn with the keypress R, which is working fine! But when the ball respawn it still have the same movement speed as it had when it died. I have tried with a vectore3.zero, but it seem to just slow the ball. Is there a way to have the vectore3.zero, or another way to have the ball to totally stop moving for like 2 second after respawn (keypress R)?
GetComponent().velocity = Vector3.zero; is what is working to slow/stop the ball, but only when it's played in Void Update. it's being ignored in Void Start and get on error other places.
using UnityEngine; using System.Collections;
public class FallRespawn : MonoBehaviour {
Vector3 respawn_Pos;
void Start () {
respawn_Pos = transform.position;
GetComponent<Rigidbody>().velocity = Vector3.zero;
}
void Update () {
if (Input.GetKeyDown(KeyCode.R))
transform.position = respawn_Pos;
}
}
Hope someone can help me out! :)
$$anonymous$$aybe try to set the rigidbody as kinematic in Start method, then reset it when you press "R" just before you reposition it.
Your answer
Follow this Question
Related Questions
How to wait a certain amount of seconds in C# 4 Answers
C# Respawn and Score Problem 1 Answer
How do i put "Wasted!" after respawn? 0 Answers
Need Help with a Level Reloading Script (c#) 1 Answer
Wait time Before Camera Switching? 0 Answers