How to reset the rotation when respawning?
I'm making a platformer and I want the player to respawn at the beginning of the level. I used this code to reset the position:
void FixedUpdate () {
if (transform.position.y < threshold)
transform.position = new Vector3(0, 0, 0);
}
This doesn't work for rotation though, does anyone know how to fix this?
Answer by dacarrera · Nov 12, 2019 at 01:08 AM
This doesn't work for rotation because as your game plays your rotation is changing and you're only updating the transform.position here. So you just need a reference to the original rotation values (define a field and assign it) and then when you reset your position (like you're doing now, above) just change the rotation values to the original value saved in your new originalRotation field.
Your answer
Follow this Question
Related Questions
Rotated object raycasting in wrong directions!!? 3 Answers
How to convert User Values into degree(Angle)?? 2 Answers
Ingame Cycle through Character Rotation 0 Answers
Check rotation of an obstacle 0 Answers