- Home /
Ball Freezes
Hello fellow developers,
I am making a rolling ball game and I ran into a problem. When the player dies, I want the player's position to reset. However, when I reset the player's position, the ball freezes for a few moments, then the player can move again. I want it where the player can be able to move as soon as the ball's position is reset. Here the section of the code I'm having trouble with:
void Start () {
maxPickUps = 0;
grounded = true;
canMove = true;
originalPosition = rigidbody.transform.position;
winText.text = "";
SetText();
}
void Update () {
if ( health <= 0 )
{
canMove = false;
Invoke( "Die", 3 );
}
}
void Die () {
rigidbody.transform.position = originalPosition;
rigidbody.velocity = Vector3.zero;
renderer.material.color = Color.white;
health = 4;
healthText.text = "Health: " + health;
canMove = true;
ColorFlickerScript.canFlicker = false;
particleSystem.Stop();
}
the "rigidbody.transform.position = originalPosition;" line resets the player's position, so the problem might be in there somehow.
Your answer
Follow this Question
Related Questions
Need insight on strange (simple) 2D object transform bug 0 Answers
Guided missile help c# 1 Answer
Making something move relative to something else, but slower/shorter ? 2 Answers
Take final position after a force applied to a GameObject 1 Answer
how to CORRECTLY position and rotate a gameobject in unity 2 Answers