- Home /
Question by
ronanskie · May 08, 2017 at 01:14 PM ·
joystickinputmanagerinput.getaxis
Joystick not responding correctly
I'm using the input manager for the first time. My goal is to control the player in all directions with the joysticks of a playstation 4 controller. This works perfectly for the left joystick. The player can move in all directions. The right joystick however doesn't work the way it's supposed to. The player should be able to rotate in all directions with this joystick, but without even touching the ps4 controller the player starts to rotate along the x-axis. My question now is how I can stop the player from automatically rotating? The player only rotates automatically along the x-axis. The rotation works fine along the y-axis.
#pragma strict
var speed : int = 300;
var rotspeed : int = 60;
function Start () {
}
function Update () {
{
var forward = Input.GetAxis("Forward") * -speed * Time.deltaTime;
var sideways = Input.GetAxis("Sideways") * speed * Time.deltaTime;
var verticalrot = Input.GetAxis("Verticalrot") * rotspeed * Time.deltaTime;
var horizontalrot = Input.GetAxis("Horizontalrot") * rotspeed * Time.deltaTime;
}
{
transform.Translate(0, 0, forward);
transform.Translate(sideways, 0, 0);
transform.Rotate(verticalrot, 0, 0);
transform.Rotate(0, horizontalrot, 0);
}
}
2017-05-04-edited.jpg
(118.7 kB)
Comment