The documentation shows the axis's but how do i apply this to my script? like this: MoveDirection = new Vector3(Input.GetAxis("left stick horizontal axis"), 0, Input.GetAxis("left stick vertical axis")); UPDATE: i got it working with this code: Code (csharp): if(RotXY == RotationAxis.MouseX) { RotationX += Input.GetAxisRaws("right stick horizontal axis") * SensitivityX * Time.deltaTime; RotationX = ClampAngle(RotationX, MinimumX, MaximumX); Quaternion XQuaternion = Quaternion.AngleAxis(RotationX, Vector3.up); _MyTransform.localRotation = OriginalRotation * XQuaternion; } however my player spins around endlessly here is the full code: Code (csharp): using UnityEngine; using System.Collections; public class FPSMouseLook : MonoBehaviour { public enum RotationAxis { MouseX = 1, MouseY = 2 } public RotationAxis RotXY = RotationAxis.MouseX | RotationAxis.MouseY; public float SensitivityX = 400f; private float MinimumX = -360f; private float MaximumX = 360f; private float RotationX = 0f; public float SensitivityY = 400f; private float MinimumY = -75f; private float MaximumY = 75f; private float MinimumYRun = -50f; private float MaximumYRun = 50f; private float RotationY = 0f; public Quaternion OriginalRotation; private Transform _MyTransform; void Start() { Application.targetFrameRate = 60; _MyTransform = transform; OriginalRotation = _MyTransform.localRotation; Screen.lockCursor = true; } void Update() { if(RotXY == RotationAxis.MouseX) { RotationX += Input.GetAxis("right stick horizontal axis") * SensitivityX * Time.smoothDeltaTime; RotationX = ClampAngle(RotationX, MinimumX, MaximumX); Quaternion XQuaternion = Quaternion.AngleAxis(RotationX, Vector3.up); _MyTransform.localRotation = OriginalRotation * XQuaternion; } if(RotXY == RotationAxis.MouseY) { //RotationY += Input.GetAxis("right stick vertical axis") * SensitivityY * Time.deltaTime; //RotationY = ClampAngle(RotationY, MinimumY, MaximumY); //Quaternion YQuaternion = Quaternion.AngleAxis(RotationY, Vector3.left); //_MyTransform.localRotation = OriginalRotation * YQuaternion; } } public static float ClampAngle(float Angle, float Min, float Max) { if(Angle < -360) { Angle += 360; } if(Angle > 360) { Angle -= 360; } return Mathf.Clamp(Angle, Min, Max); } void OnGUI() { GUI.Label(new Rect(Screen.width / 2, Screen.height / 2, 200, 200), "Right H: " + Input.GetAxis("right stick horizontal axis").ToString() + " Right V: " + Input.GetAxis("right stick vertical axis").ToString() + " H Raw: " + Input.GetAxisRaw("right stick horizontal axis").ToString() + " V Raw: " + Input.GetAxisRaw("right stick vertical axis").ToString()); } }
right stick horizontal axis 4th axis left: negative, right: positive right stick vertical axis 5th axis up: negative, down: positive right/left button 6th axis left: -1, right: 1, default: 0 why is there no default for the sticks?
The sticks are analog so what would they default to exactly? With analog sticks the best you can do is define a dead zone.
Here is an example project that maps all the input to various actions. Joysticks (x/y/4th/5th axis) are mapped in the InputManager, and read from scripts. Buttons are read directly with Input.GetKey(<string>). Touch uses the standard Input.GetTouch() etc.
Thanks eriQue i have one more problem i'll post it here in a minute EDIT: are realtime shadows possible on the vita? whenever i run my game they dissapear
Thanks for the example project eriQue! Is there a pool of these types of examples somewhere we can all access?
Got my touch screen game working on vita, analogue sticks, triggers and everything haha so awesome, beats touch screen controls anyday!
i am making top down game like angrybot. i am using angrybots script for my player. the player moves and rotate well with both right and left joysticks but i can not handle its animation. My player has its own animation. I do not know what to do. specially firing animation is not running with angrybot script. any suggestions ??