I have been trying to set up a scene where a cube moves when the left joystick is moved, and rotates when the right is moved. Basically I am trying to make a basic twin stick shooter.
Using some code provided here: Twin Stick Shooter - Questions & Answers - Unity Discussions
var moveSensitivity : float = 3.0;
function Update() {
var lh : float = Input.GetAxis("LeftStickHorizontal");
var lv : float = Input.GetAxis("LeftStickVertical");
var rh : float = Input.GetAxis("RightStickHorizontal");
var rv : float = Input.GetAxis("RightStickVertical");
//Assumes you're looking down the z axis
transform.position += Vector3(lh, lv, 0.0).normalized * moveSensitivity
* Time.deltaTime;
//Assumes you're looking down the z axis and that you are looking down on the avatar
transform.LookAt(transform.position + Vector3(rh, rv, 0.0), -Vector3.forward);
}
I set up my inputs up accordingly and made them x or y-axis only and the types to joystick. But for some reason it still does not work. I am not getting any errors from the editor.
I think the reason my cube isn’t moving is because my rh and rl (etc) values are fixed at zero. How come they don’t change from between 1 to -1 (when I move my joysticks) like they are supposed to.
All help is appreciated. Thanks