- Home /
Question by
Ironscreamer · Jul 26, 2019 at 09:50 AM ·
space shooter2d rotation
How to make 2d obj rotate with mobile joystick??,how to make 2d character rotate using touch joystick
I want to make a 2d character rotate according to its movement in x and y axis with joystick how can I do it ,I want to make a 2d spaceship kinda of thing rotte with joystick like if the obj is moving in horizontal it would give me a rotation of some degrees if in both x and y some degrees how can I do it ??
Comment
Answer by brzydal · Jul 28, 2019 at 10:20 AM
So i assume that your joystick gives you a Vector2?
private void RotateShipAlongJoystick(Vector2 JoystickInput)
{
transform.forward = new Vector3(joystickInput.x, 0f, joystickInput.y);
}
if your ship doesn't looking along blue axis you can play with transform.up
or transform.right
.