- Home /
How to make Y-Axis face away from a position?
Hi, I'm trying to make a game, where the player can jump from planet to planet. Therefore I need for the player's Y axis to always be facing away from the current planet. The LookAt method doesn't let my player rotate around the Y axis. Can someone please tell me how to do it?
Answer by Vega4Life · Dec 14, 2018 at 07:40 PM
If you are looking to rotate around a planet then this would work. Essentially, we get our bearing by getting the difference from our two objects. This bearing is the same line we want our character to be parallel with. So we just set it to our transform up. Now the bottom of our character is always pointing towards the planet center.
Vector3 direction = transform.position - target.transform.position;
transform.up = direction;
Thats exactly what I don't want. The player has to be able to rotate around the Y axis from the $$anonymous$$ouse X - input. Here's a sketch of how it should look. Please consider that my player is in first person. @Vega4Life
So its like the character is walking around the planet?
Updated my answer, but that is assu$$anonymous$$g you want to walk around a planet.