How to make player rotate using the If Else Loop?
I was trying something like this:
if (plInput.jump == true)
{
if("If players Quaternion range is < 0f")
{
Player will instantly make a 180 degree turn.
}
else if("If players Quaternion range is > 0f")
{
Player will instantly make a 0 degree turn.
}
}
But I don't know what is the proper way to code it. Sorry if I can't explain it well.
Answer by LMan · Jun 21, 2016 at 12:44 AM
You can put a direction to face into LookRotation and get a quaternion that fits into transform.rotation. Don't forget that turning 180 degrees is the same as the inverse of the current transform.forward so you could get that direction by just putting it as (-transform.forward.)
If you know the degrees you want to turn but not the direction, you can use AngleAxis to return the rotation you want.
If you have a specific object you want to face, you can use LookAt to just input the object transform you want to face towards.
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
Freeze rotation X but rotation Z, how can I do this? 0 Answers