- Home /
Character Controller Respawn (Rotation Issue)
Hi, I'm trying to make my character (who uses the default character controller script) respawn after "dying". However, there are three problems:
First: It's facing the rotation it was in when it died. Now I know you're not able to rotate the char. con. on the x and z axis but I thought y worked? I've tried every rotation code I could think of and it just won't budge.
Second: It still carries it's original velocity. This isn't too terrible of a problem (I just spawn it very close to the ground to avoid leap offs), It would just be nice if I could somehow set it's velocity to zero, if possible.
Third: The camera manually moves from the position the character died in to the spawn point, and it looks a little sloppy. Is there any way to reset the camera in the char. con. script so that it just instantaneously appears behind the character in the direction it's facing? (this is not a huge problem, I can just cover it up).
There's not much code to look at but here's the code I'm using right now, to no avail:
gameObject.transform.eulerAngles.y = 0;
gameObject.transform.position = Vector3(0, 40.6, 156);
Answer by ninjarob · Oct 30, 2011 at 09:02 PM
Build the player and camera as a prefab then instead of moveing the player to respawn Destroy and instantiate that should reset all of the varables in the scripts.