- Home /
Face the direction of my Joystick
Hello, I am creating a 3D topdown shooter like game and am having an issue with making the object face the direction of the Joystick. I am using the MobileSingleJoystick asset. I only want the object to face the direction of the joystick.
ie. There is a turret on top of a vehicle, I want the turret to face in the direction of the joystick. Thanks.
Here is my code
var turnSpeed: float = 90;
var speed: float = 60; // rotate 60 degrees per second
function Update () {
var joystickHorizontal = UnityStandardAssets.CrossPlatformInput.CrossPlatformInputManager.GetAxis("Horizontal");
var joystickVertical = UnityStandardAssets.CrossPlatformInput.CrossPlatformInputManager.GetAxis("Vertical");
transform.Rotate(Vector3(joystickVertical,0,joystickHorizontal)*turnSpeed* Time.deltaTime);
}
Comment
Your answer
Follow this Question
Related Questions
Fenerax's Joystick problem 0 Answers
How do I do a double Floating joystick? (Direction and movement (one for each))? 0 Answers
2D shooting with mobile joystick 1 Answer
Make gameObject face position of Joystick [Mobile] 4 Answers
Mobile Joystick 0 Answers