- Home /
Facing the players game object (upward, downward, left, right) on Android phone using joystick
I am creating a 2d top down game and its going good. But i have a problem with my controller joystick. As of now, i have only a left and right movement which has an animation. But i need to have a upward and downward also to make the player game object more flexible.
x_position = transform.position.x;
y_position = transform.position.y;
if (x_position < transform.position.x) {
facing = "left";
} else if (x_position > transform.position.x){
facing = "right";
}
x_position = transform.position.x;
y_position = transform.position.y;
If my game is only for pc, I can use Input.GetAxis() to do the logic. But this is for mobile and im having a hard time solving this problem. How can i fix this?
Comment