So I have this game idea where it involes natural disasters like a tornado and im wondering if there is a way to have the player stand back up either automaticly or with a button, because right now when the player gets thrown form the tornado they are on their side, what I would like is if the player could stand back up when they hit the ground. If anybody has a script or ideas that i could use then that would be great.
You stand the player up by setting the player’s Transform rotation appropriately, such as back to what it was before they got knocked over.
You can do it instantaneously by assigning the new rotation, or you could animate it over time.
As for making the player animate himself from lying down to standing, that involves animation.
Whatever you do will absolutely be done precisely one step at a time, just like how this guy does it:
Imphenzia: How Did I Learn To Make Games:
So I got the code to detect if the gameobject hitting the ground is the player and to see if the players rotaion is greater than one but now i need help trying to figure out how to set the players rotation back to 0. I need help on what to put in the second if statment to reset the rotation.
heres my script
public GameObject player;
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "player")
{
if (player.transform.rotation.eulerAngles.z >= 1 || player.transform.rotation.eulerAngles.x >= 1)
{
}
}
}
}
You can assign Quaternion.identity to the rotation in order to restore a default rotation, something like:
player.transform.rotation = Quaternion.identity;
Otherwise you would need to track whatever the last “acceptably vertical” rotation was and restore that instead.
Here’s some more reading:
All about Euler angles and rotations, by StarManta:
https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html