// Update is called once per frame void Update() { if (TestJoystick) { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR #else if (Input.GetMouseButtonDown(0)) { //get inputs from SwipeInput.script } if (Input.GetMouseButton(0)) { } if (Input.GetMouseButtonUp(0)) { } Vector2 touchPos = Input.mousePosition; #endif } }
// Update is called once per frame void Update() { if (testJoystick) { //Test joystick transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { //Platform directives - similar to regions but as an if statement #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR //Platform specific //Mobile Input HERE #else //Touch start emulation if (Input.GetMouseButtonDown(0)) //Left click { } //Touch update emulation if (Input.GetMouseButtonDown(0)) { } //Touch end emulation if (Input.GetMouseButtonUp(0)) { } //Touch position emulator Vector2 touchPos = Input.mousePosition; #endif } }
void Update() { if (testJoystick) { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR //mobile input here #else if (Input.GetMouseButtonDown(0)) //left click start { } if (Input.GetMouseButton(0)) //left click update { } if (Input.GetMouseButtonUp(0)) //left click end { } Vector2 touchPos = Input.mousePosition; #endif } }
private void Update() { if (testJoystick) { transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; transform.position += transform.up * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; } if (testSwipe) { #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR // touch inputs here #else // Touch position emulation. Vector2 touchPos = Input.mousePosition; // Touch start emulation. if (Input.GetMouseButtonDown(0)) { } // Touch update emulation. if (Input.GetMouseButton(0)) { } // Touch end emulation. if (Input.GetMouseButtonUp(0)) { } #endif } }
private void FixedUpdate() { if (!canPlayerMove) { return; } // Switch between Mobile and PC Input #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR // Mobile Inputs float moveHorizontal = MobileInput.GetJoystickAxis(JoystickAxis.Horizontal); float moveVertical = MobileInput.GetJoystickAxis(JoystickAxis.Vertical); #else // PC Inputs float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); #endif // calculate movement for both inputs Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); rb.velocity = (movement) * speed; }
protected override void OnRun(params object[] _params) { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime * 25; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime * 25; }
// Update is called once per frame void Update() { transform.position += transform.forward * MobileInput.GetJoystickAxis(JoystickAxis.Vertical) * Time.deltaTime; transform.position += transform.right * MobileInput.GetJoystickAxis(JoystickAxis.Horizontal) * Time.deltaTime; }