private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxisRaw("Horizontal"); //AMCLEAN changed GetAxis to GetAxisRaw float vertical = CrossPlatformInputManager.GetAxisRaw("Vertical"); //AMCLEAN changed GetAxis to GetAxisRaw bool waswalking = _isWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running _isWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running //speed = _isWalking ? walkSpeed : runSpeed; speed = PlayerPrefs.GetFloat("MoveSpeed") * 10; _input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (_input.sqrMagnitude > 1) { _input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (_isWalking != waswalking && useFOVKick && _characterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_StartSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); bool waswalking = m_IsWalking; // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
public void GetInput(out float speed) { float horizontal = 0.0f; float vertical = 0.0f; if (PlayerNumber == 1) { horizontal = -Input.GetAxis("PlayerOne_Vertical"); vertical = Input.GetAxis("PlayerOne_Horizontal"); } if (PlayerNumber == 2) { horizontal = -Input.GetAxis("PlayerTwo_Vertical"); vertical = Input.GetAxis("PlayerTwo_Horizontal"); } bool waswalking = isWalking; if (PlayerNumber == 1) { isWalking = !Input.GetButtonDown("PlayerOne_Jump"); } if (PlayerNumber == 2) { isWalking = !Input.GetButtonDown("PlayerTwo_Jump"); } if (isWalking) { speed = walkSpeed; } else { speed = runSpeed; } userInput = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (userInput.sqrMagnitude > 1) { userInput.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (isWalking != waswalking && useFovKick && characterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); if (isWalking) { StartCoroutine(fovKick.FOVKickUp()); } else { StartCoroutine(fovKick.FOVKickDown()); } } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; // Prevents movement when character is jumping if (!m_Jumping) { m_Input = new Vector2(horizontal, vertical); } // System is only allow the character to run for a set amount of time if (m_IsWalking == false) { m_runTime -= Time.deltaTime; } if (m_runTime <= 0.02) { m_IsWalking = true; m_RunSpeed = m_WalkSpeed; } if (m_RunSpeed == 5) { m_runTime += Time.deltaTime; } if (m_runTime == m_setRunTime) { m_RunSpeed = m_setRunSpeed; } if (m_runTime >= m_setRunTime) { m_runTime = m_setRunTime; } // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input //horizontal Right-Left Movement //Vertical Up-Down Movement float horizontal = 0; // = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = 0; // = CrossPlatformInputManager.GetAxis("Vertical"); Debug.DrawRay(transform.position, cam.transform.forward * 100, Color.red); Debug.DrawRay(transform.position, transform.forward * 100, Color.green); angGO = new Vector2(transform.forward.x, transform.forward.z); angCam = new Vector2(cam.transform.forward.x, cam.transform.forward.z); angle = Vector2.SignedAngle(angGO, angCam); if (Input.GetKey(KeyCode.B) || canMove) { horizontal = -Mathf.Sin(angle * Mathf.PI / 180f); vertical = Mathf.Cos(angle * Mathf.PI / 180f); //print("Angle: " + angle + " ( Horizontal: " + horizontal + " Sin: " + Mathf.Sin(angle) + " ) " + " ( Vertical: " + vertical + " Cos: " + Mathf.Cos(angle) + " ) "); } else { horizontal = 0; vertical = 0; } bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } if (Input.GetKey(KeyCode.LeftShift)) { m_CharacterController.height = originalHeight / 8; m_IsCrouching = true; } else { m_CharacterController.height = originalHeight; m_IsCrouching = false; } if (Input.mouseScrollDelta.y < 0) { int slot = (selectedWeapon - 1 < 0) ? weapons.Length - 1 : selectedWeapon - 1; SelectWeapon(slot); } else if (Input.mouseScrollDelta.y > 0) { int slot = (selectedWeapon + 1 == weapons.Length) ? 0 : selectedWeapon + 1; SelectWeapon(slot); } if (weapon != null) { weapon.isRunning = !m_IsWalking; } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input. // if (GvrController.IsTouching) { // speed = 10f; // m_Input = GvrController.TouchPos; // if (m_Input.sqrMagnitude > 1) // { // m_Input.Normalize(); // } // return; // } if (CrossPlatformInputManager.GetButtonDown("Recenter")) { UnityEngine.VR.InputTracking.Recenter(); } float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); #if UNITY_HAS_GOOGLEVR && (UNITY_ANDROID || UNITY_EDITOR) horizontal = GvrController.ClickButton ? 0f : horizontal; vertical = GvrController.ClickButton ? 1f :vertical; #endif Debug.Log("Unit#: horizontal = " + horizontal + " vertical = " + vertical); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // Debug.Log ("Unit#: Is Touching = " + GvrController.ClickButton + " X = " + GvrController.TouchPos.x + " Y = " + GvrController.TouchPos.y); // Debug.Log ("Unit#: x_accel = " + GvrController.Accel.x + " y_accel = " + GvrController.Accel.y + " z_accel = " + GvrController.Accel.z); // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = _isWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running _isWalking = !Input.GetKey(KeyCode.LeftShift); //moritz if (vertical > 0) { nowWalking = true; } if (vertical <= 0) { nowWalking = false; } bool Crouch = Input.GetButton("Fire2"); if (Crouch) { _isWalking = true; } //new animations for input variables moritz // anim.SetBool("Sprint", !_isWalking); anim.SetBool("Crouch", Crouch); anim.SetBool("Walking", nowWalking); #endif // set the desired speed to be walking or running speed = _isWalking ? walkSpeed : runSpeed; _input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (_input.sqrMagnitude > 1) { _input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (_isWalking != waswalking && useFOVKick && _characterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown()); } }
private void CheckFOVKick() { bool waswalking = !isRunning; // handle speed change to give an fov kick only if the player is going to a run, is running and the fovkick is to be used if (!isRunning != waswalking && useFovKick && controller.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(isRunning ? fovKick.FOVKickUp() : fovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal; float vertical; if (canMove) { horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); vertical = CrossPlatformInputManager.GetAxis("Vertical"); } else { horizontal = 0; vertical = 0; } //transform.Rotate(0,horizontal*90*Time.deltaTime*2,0,Space.Self); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); //print(vertical); if (vertical == 0) { anim.SetBool("isMove", false); //Cmd_rabbit_anim_stop(); } else { anim.SetBool("isMove", true); //Cmd_rabbit_anim_move(); } //Cmd_rabbit_anim(vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = true; m_IsCrouched = Input.GetKey(KeyCode.LeftControl); bool prevDash = m_IsDashing; m_IsDashing = (Input.GetKey(KeyCode.LeftShift) && m_Energy > 99 && !prevDash) || (Input.GetKey(KeyCode.LeftShift) && m_Energy > 32 && prevDash) ; if (m_IsDashing) { //m_AudioSource.clip = dashClip;// m_JumpSound; //m_AudioSource.Play(); if (m_Energy > 99) { DashAudioSource.PlayOneShot(dashClip, 0.6f); } //SoundManager.PlaySingleSfx(dashClip); Camera.main.GetComponent <CameraEffects>().DashCameraZoom(); isDashing_delayed = true; Invoke("setDashingDelayedFalse", 0.5f); } #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; if (m_IsDashing) { speed = m_RunSpeed * m_DashMultiplier; } m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput() { // Read input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); waswalking = m_IsWalking; // m_IsCrouching = Input.GetButton("Crouch"); // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running //if (!m_IsCrouching) { // m_IsWalking = !Input.GetButton("Sprint"); // if (!m_Jump) { // m_Jump = Input.GetButtonDown("Jump"); } } // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running if (running && anim.GetInteger("Attack") != 0) { justAttack = Time.realtimeSinceStartup; } if (Time.realtimeSinceStartup <= justAttack + 4) { m_IsWalking = true; speed = m_WalkSpeed; } if (anim.GetBool("Protected")) { m_IsWalking = true; speed = m_WalkSpeed / 2; } else { m_IsWalking = !Input.GetKey(KeyCode.LeftShift); speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; } #endif // set the desired speed to be walking or running // if (anim.GetBool("Protected") && !anim.GetBool("isRunning")) // speed = m_WalkSpeed/2; // else // speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
//აქ დაწერილია სიარულის სკრიფტი private void GetInput(out float speed) { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); if (!IsGrounded) { if (!skipMovement) { moveHozBeforeJump = horizontal; moveVertBeforeJump = vertical; skipMovement = true; } else { horizontal = moveHozBeforeJump; vertical = moveVertBeforeJump; } } else { skipMovement = false; } bool waswalking = m_IsWalking; if (!m_IsAiming) { speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; } else { speed = m_WalkSpeed * 0.8f; } m_Input = new Vector2(horizontal, vertical); if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
// void OnCollisionEnter (Collision col) // { // // Destroy(col.gameObject); // print (gameObject.name); // // if(col.gameObject.name == "Floor") // { // // Destroy(gameObject); // // print ("HEY"); // // GameObject player = GameObject.Find (col.gameObject.name); // // player.transform.position.Set (0, 0, 10); // // } // } // private float GetInput() //now returns a float. no longer takes out speed { // Read input float horizontal = Random.Range(-1, 2); float vertical = Random.Range(-1, 2); if (m_CharacterController.transform.position.x > 25) { horizontal = Random.Range(-1, 1); } else if (m_CharacterController.transform.position.x < -25) { horizontal = Random.Range(0, 2); } if (m_CharacterController.transform.position.z > 25) { vertical = Random.Range(-1, 1); } else if (m_CharacterController.transform.position.z < -25) { vertical = Random.Range(0, 2); } bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } return(speed); }
static int FOVKickDown(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); FOVKick obj = (FOVKick)ToLua.CheckObject <FOVKick>(L, 1); System.Collections.IEnumerator o = obj.FOVKickDown(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void GetInput(out float speed) { if (Cursor.visible) { m_Input = new Vector2(0f, 0f); speed = 0f; return; } // Read input var horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); var vertical = CrossPlatformInputManager.GetAxis("Vertical"); var waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !CrossPlatformInputManager.GetButton("Sprint"); #endif // set the desired speed to be walking or running speed = m_Flying ? m_FlySpeed : m_WalkSpeed; if (!m_IsWalking) { speed *= m_SprintMultiplier * (CrossPlatformInputManager.GetButton("Sprint2") ? 5f : 1f); } m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { float power = 4f; float ang = m_agent.action.rotate * 90f / 16f + 5.0f * CrossPlatformInputManager.GetAxis("Horizontal"); transform.rotation *= Quaternion.Euler(new Vector3(0, ang, 0)); // Read input float horizontal = 0; float vertical = m_agent.action.forward * power + CrossPlatformInputManager.GetAxis("Vertical"); m_Jump = m_Jump || m_agent.action.canJump; if (m_Jumping) { m_Jump = false; } //m_agent._actAppliedCnt++; //bool waswalking = m_IsWalking; /* #if !MOBILE_INPUT * // On standalone builds, walk/run speed is modified by a key press. * // keep track of whether or not the character is walking or running * m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif */ // set the desired speed to be walking or running speed = m_RunSpeed * m_agent.action.scale; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: // if (m_Input.sqrMagnitude > 1) // { // m_Input.Normalize(); // } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (/*m_IsWalking != waswalking && m_UseFovKick &&*/ m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input var horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); var vertical = CrossPlatformInputManager.GetAxis("Vertical"); var waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running if (m_Submerged) { speed = m_IsWalking || m_Stamina == 0 ? m_SwimSpeed : m_QuickSwimSpeed; } else { speed = m_IsWalking || m_Stamina == 0 ? m_WalkSpeed : m_RunSpeed; } m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } // Update stanima // TODO Maybe add a new capacity for stanima? m_Stamina = !m_IsWalking?Mathf.MoveTowards(m_Stamina, 0f, Time.deltaTime *m_LungCapacity * 2) : m_Stamina = Mathf.MoveTowards(m_Stamina, 1f, Time.deltaTime * m_LungCapacity * 5); }
private void GetInput(out float speed) { if (_gameManager.HumanNumPadActive || _inventory.InventoryActive || _gameManager.HumanMapActive || _gameManager.HumanController.Health <= 0 || _gameManager.HumanImageCanvasActive || _startMenu.MenuActive) { speed = 2; return; } // Read input var horizontal = CrossPlatformInputManager.GetAxis(ButtonNames.MoveHumanX); var vertical = CrossPlatformInputManager.GetAxis(ButtonNames.MoveHumanY); var waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Character.Animator.SetFloat("Dirx", horizontal); Character.Animator.SetFloat("Diry", vertical); m_isIdle = horizontal == 0 && vertical == 0; bool waswalking = m_isWalking; m_isWalking = !Input.GetKey(KeyCode.LeftShift); if (!m_isWalking && CurrentStamina == 0) { m_isWalking = true; } // set the desired speed to be walking or running speed = m_isWalking ? m_walkSpeed : m_runSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_isWalking != waswalking && m_useFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_isWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } else { } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); /*// Use last device which provided input. * var inputDevice = InputManager.ActiveDevice; * * // Disable and hide touch controls if we use a controller. * // If "Enable Controls On Touch" is ticked in Touch Manager inspector, * // controls will be enabled and shown again when the screen is touched. * if (inputDevice != InputDevice.Null && inputDevice != TouchManager.Device) { * TouchManager.ControlsEnabled = false; * }*/ bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); //locks camera control to allow UI specific control, and vice versa //added to first person controller script as it only impacts the FPS controller activity? if (Input.GetKeyDown(KeyCode.Escape) && lockCameraDelay <= 0) { m_LockedCamera = !m_LockedCamera; m_MouseLook.SetCursorLock(m_LockedCamera); lockCameraDelay = 1.5f; } // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
private void GetInput(out float speed) { // Read input var horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); var vertical = CrossPlatformInputManager.GetAxis("Vertical"); var waswalking = _isWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running _isWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running if (_underWater.IsSubmerged()) { speed = _isWalking || !_stamina.HasStamina() ? _swimSpeed : _quickSwimSpeed; } else { speed = _isWalking || !_stamina.HasStamina() ? _walkSpeed : _runSpeed; } _input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (_input.sqrMagnitude > 1) { _input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to run, is running and the fovkick is to be used if (_isWalking != waswalking && _useFovKick && _characterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown()); } }
private Vector2 GetInput() { Vector2 input = new Vector2 { x = Input.GetAxis("Horizontal"), y = Input.GetAxis("Vertical") }; movementSettings.UpdateDesiredTargetSpeed(input); bool wasWalking = !Running; Running = Input.GetKey(KeyCode.LeftShift); //Keep track of whether or not the character is walking or running. if (!Running != wasWalking && useFovKick && rigidBody.velocity.sqrMagnitude > 0f) { StopAllCoroutines(); StartCoroutine(Running ? fovKick.FOVKickUp() : fovKick.FOVKickDown()); } return(input); }
void GetInput(out float speed) { // Read input float horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); float vertical = CrossPlatformInputManager.GetAxis("Vertical"); bool wasRunning = isRunning; isRunning = Input.GetKey(KeyCode.Space); slowWalk = Input.GetKey(KeyCode.LeftShift); // set the desired speed to be walking or running speed = m_WalkSpeed; if (isRunning) { speed = m_RunSpeed; } if (slowWalk) { speed = m_SlowWalkSpeed; } m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (isRunning != wasRunning && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!isRunning ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }
void GetInput(out float speed) { // Read input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif speed = DesiredSpeed(); m_Input = new Vector2(horizontal, vertical); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } if (m_ControllerExt) { bool isMoving = (m_Input != Vector2.zero); Vector2 animationSpeed = m_IsWalking ? m_Input * 0.5f : m_Input; m_ControllerExt.OnMove(isMoving, animationSpeed, false); } }
private void GetInput(out float speed) { // Read input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); bool waswalking = m_IsWalking; #if !MOBILE_INPUT // On standalone builds, walk/run speed is modified by a key press. // keep track of whether or not the character is walking or running m_IsWalking = !Input.GetKey(KeyCode.LeftShift); #endif // set the desired speed to be walking or running speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed; m_Input = new Vector2(horizontal, vertical); Debug.Log(headTransform.rotation.y); m_Input = Quaternion.Euler(0, 0, 360f - headTransform.eulerAngles.y) * m_Input; // animate bool walking = horizontal >= 0.1f || vertical >= 0.1f; m_Anim.SetBool("IsWalking", walking); // normalize input if it exceeds 1 in combined length: if (m_Input.sqrMagnitude > 1) { m_Input.Normalize(); } // handle speed change to give an fov kick // only if the player is going to a run, is running and the fovkick is to be used if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0) { StopAllCoroutines(); StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown()); } }