- Home /
Getting the face direction
I am now working on a 2.5D platformer and i am trying to find a way to find out in which direction the character is looking. Consider this, I am using touchpads to move the character.
I have a gameobject called crosshairGO. Its rotation represents where the character is looking and its position where the character is standing. If i touch the lower left part of the touchpad i want the character to look to the lower left. Any ideas on how to do that?
Answer by Kleptomaniac · Apr 21, 2012 at 05:59 AM
To determine the direction that your character is facing, try Transform.forward.
To rotate an object based on the position of another gameObject, try Transform.LookAt like so:
Transform.LookAt(crosshairGO.transform.position);
Did that help? I'm not sure if that's what you wanted.
Klep
Answer by MarveUnity · May 04, 2012 at 11:27 AM
The problem is we don't have a second object to look at. We are are using the joystick to try and determine where the charater is aiming.