public Move ( |
||
move | ||
crouch | bool | |
jump | bool | |
리턴 | void |
private void Update() { timeLeft -= Time.deltaTime; if (m_activated) { m_activated_delay -= Time.deltaTime; if (m_activated_delay < 0) { Vector3 predictionPos = transform.position; owner.GetComponent <UnityEngine.AI.NavMeshAgent>().Warp(predictionPos); owner.transform.position = predictionPos + Vector3.up * 0.1f; owner.GetComponent <UnityEngine.AI.NavMeshAgent>().ResetPath(); Destroy(gameObject); return; } } if (timeLeft < 0 && !m_activated) { DestroySpell(); return; } if (target != null) { agent.SetDestination(target.position); } if (agent.remainingDistance > agent.stoppingDistance) { thirdPersonController.Move(agent.desiredVelocity, false, false); } else { thirdPersonController.Move(Vector3.zero, false, false); } }
void patrol() { Vector3 target = waypoint[currentWaypoint].position; target.y = transform.position.y; // $$anonymous$$eep waypoint at character's height Vector3 moveDirection = target - transform.position; if (moveDirection.magnitude < 0.5f) { if (curTime == 0) { curTime = Time.time; // Pause over the Waypoint } if ((Time.time - curTime) >= pauseDuration) { currentWaypoint++; curTime = 0; } } else { var rotation = Quaternion.LookRotation(target - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * dampingLook); character.Move(moveDirection.normalized * patrolSpeed, false, false); } }
private void Move() { if (target != null) { agent.SetDestination(target.position); } if (agent.remainingDistance > agent.stoppingDistance) { character.Move(agent.desiredVelocity, false, false); } else { character.Move(Vector3.zero, false, false); } }
private void Update() { if (target != null) { agent.SetDestination(target.position); } if (agent.remainingDistance > agent.stoppingDistance) { thirdPersonController.Move(agent.desiredVelocity, false, false); } else { thirdPersonController.Move(Vector3.zero, false, false); } }
// Update is called once per frame void Update() { // Movement if there is a target to move to if (target != null) { agent.SetDestination(target.position); } if (agent.remainingDistance > agent.stoppingDistance) { character.Move(agent.desiredVelocity, false, false); } else { character.Move(Vector3.zero, false, false); } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h, v; if (Application.isEditor) { h = Input.GetAxis("Horizontal"); v = Input.GetAxis("Vertical"); } else { h = -Input.acceleration.x; v = -Input.acceleration.z; } bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift) && Application.isEditor) { m_Move *= 0.5f; } if (v > 0.01f) { audioSource.UnPause(); } else { audioSource.Pause(); } // pass all parameters to the character control script m_Character.Move(m_Move * 3f, crouch, m_Jump); m_Character.transform.Rotate(Input.acceleration.x * m_Cam.up * 3f); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = _veritcal * m_CamForward + _horizontal * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = _veritcal * Vector3.forward + _horizontal * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script if (player_made_move) // This ensures movement vector isn't passed to character controller unless the player intends to be moving // (otherwise, when at a stand-still but moving the camera, player character will still turn to reorient himself relative // to the camera forward position, which is how it works in for example Jedi Outcast, Indiana Jones Emperor's Tomb IIRC // but is not used in newer games like Sleeping Dogs or even Zelda Wind Waker iirc { m_Character.Move(m_Move, crouch, m_Jump); } else { m_Character.Move(Vector3.zero, crouch, m_Jump); } m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { if (!isCaught) { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.LeftControl); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; } else { m_Character.Move(new Vector3(0, 0, 0), true, false); } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = 0; if (Input.GetKey(KeyCode.A)) { h = -1; } if (Input.GetKey(KeyCode.D)) { h = 1; } float v = 0; if (Input.GetKey(KeyCode.S)) { v = -1; } if (Input.GetKey(KeyCode.W)) { v = 1; } bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs bool crouch = Input.GetKey(KeyCode.C); float v = Mathf.Abs(CrossPlatformInputManager.GetAxis("Vertical")); m_Move = v * Vector3.forward; // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
private void Update() { character.GetComponentInChildren <Camera> ().transform.LookAt(player); if (IsObjectCloserThan(player, 5f)) { Debug.Log(character.tag + " is running away!"); MoveFromPlayer(); } else { Debug.Log(character.tag + " is hiding!"); Transform wall = FindClosestWall(); if (!IsObjectCloserThan(wall, 3f)) { MoveToObject(wall); } else { character.Move(Vector3.zero, false, false); } } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs bool crouch = Input.GetKey(KeyCode.C); #if !MOBILE_INPUT // walk speed multiplier #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, false, m_Jump); m_Jump = false; }
void Patrol() { agent.speed = patrolSpeed; if (Vector3.Distance(this.transform.position, waypoints[waypointInd].transform.position) >= 2) { agent.SetDestination(waypoints[waypointInd].transform.position); character.Move(agent.desiredVelocity, false, false); } else if (Vector3.Distance(this.transform.position, waypoints[waypointInd].transform.position) <= 2) { waypointInd++; if (waypointInd >= waypoints.Length) { waypointInd = 0; } } else { character.Move(Vector3.zero, false, false); } }
// private void LateUpdate(){ // oldPosition = transform.position; // } // Fixed update is called in sync with physics private void FixedUpdate() { if (amIServer == networkObject.IsServer) { Camera.main.GetComponent <TPMCameraMove>().setServer(amIServer); // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 2.0f; } #endif m_Character.Move(m_Move, crouch, m_Jump); // networkObject.SendRpc(RPC_MOVE, Receivers.AllBuffered, transform.position, transform.rotation); networkObject.SendRpc(RPC_MOVE, Receivers.AllBuffered, m_Move, crouch, m_Jump); m_Jump = false; } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); print("h: " + h + ", v: " + v); if (Application.loadedLevelName != "Base") { crouch = CrossPlatformInputManager.GetButton("Crouch"); } // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier var attack = GetComponent <ThirdPersonLogic>(); if (attack.isAttacking == true) { m_Move *= 0f; } else { m_Move *= 1f; } if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } if (Input.GetKey(KeyCode.R)) { m_Move *= 100.0f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { //added code float h = 0f; float v = 0f; // read inputs according to character's name if (this.name == "Guardian") { h = CrossPlatformInputManager.GetAxis("Horizontal1"); v = CrossPlatformInputManager.GetAxis("Vertical1"); } else if (this.name == "thief1") { h = CrossPlatformInputManager.GetAxis("Horizontal2"); v = CrossPlatformInputManager.GetAxis("Vertical2"); } else { h = CrossPlatformInputManager.GetAxis("Horizontal3"); v = CrossPlatformInputManager.GetAxis("Vertical3"); } //added code ends here bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); m_Input = new Vector2(h, v); bool crouch = Input.GetKey(KeyCode.C); Vector2 facingDirection = new Vector2(h, v); Vector3 desiredMove = transform.forward * m_Input.y + transform.right * m_Input.x; // get a normal for the surface that is being touched to move along it RaycastHit hitInfo; Physics.SphereCast(transform.position, controller_radius, Vector3.down, out hitInfo, controller_height / 2f, Physics.AllLayers, QueryTriggerInteraction.Ignore); desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized; float speed = 1.0f; #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { speed = 1.5f; } #endif m_MoveDir.x = desiredMove.x * speed; m_MoveDir.z = desiredMove.z * speed; /* * // calculate move direction to pass to character * if (m_Cam != null) * { * // calculate camera relative direction to move: * m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; * m_Move = v*m_CamForward + h*m_Cam.right; * } * else * { * // we use world-relative directions in the case of no main camera * m_Move = v*Vector3.forward + h*Vector3.right; * } */ // pass all parameters to the character control script m_Character.Move(m_MoveDir, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: //Debug.Log("hello"); //m_CamForward = Vector3.Scale (m_Cam.forward, new Vector3 (1, 0, 1)).normalized; //m_Move = v*m_CamForward + h*m_Cam.right; //mata change the moving direction calculation. Vector3 _camForward = Vector3.Normalize(transform.position - m_Cam.position); _camForward = m_Cam.forward; Vector3 _camRight = Vector3.Normalize(Vector3.Cross(_camForward, Vector3.up)); _camRight = m_Cam.right; if (transform.up.y < -0.8f) { m_Move = v * Vector3.Normalize(Vector3.Cross(_camRight, _camForward)) + h * _camRight; }//player on the ceil else if (transform.up.y > 0.8f) { m_Move = v * _camForward + h * _camRight; }//player on the floor else { m_Move = v * Vector3.up + h * _camRight; }//player on the wall //m_Move = v * this.gameObject.transform.forward + h * this.gameObject.transform.right; } else { // we use world-relative directions in the case of no main camera //m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier //if (Input.GetKey (KeyCode.LeftShift)) m_Move *= 0.5f; //mata :no walking mode #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
void Wonder() { agent.speed = patrolSpeed; //Uzstāda ātrumu kādā pārvietosies AI if (Vector3.Distance(this.transform.position, waypoints[random].transform.position) >= 1f) //novērtē vai distance starp AI un waypoiuntu ir >= 1 { agent.SetDestination(waypoints[random].transform.position); //Uzstāda aģentam mērķi character.Move(agent.desiredVelocity, false, false); // Notiek AI kustēšanās uz mērķi } else { //Ja ir sasniedzis mērķi character.Move(Vector3.zero, false, false); //Aptur AI kustību int num = UnityEngine.Random.Range(1, 3); //nosaka num vērtību izmantojot random(50% iespēja) if (num == 1) { state = basicAI.State.TROLLING; // maina state uz trolling } else { state = basicAI.State.LOOKING; // maina state uz looking } } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs // Create a parent gameObject that is the Agent. // Move these into the Agent's Heuristic(). // Create a public variable for forward and sideways in this script // Reference it in the Agent script: userControl = GetComponentInChildren<ThirdPersonUserControl>(); // And set the vaule of it in OnActionReceived() { // userControl.verticalInput = vectorAction[0]; // userControl.horizontalInput = vectorAction[1]; } // // float h = horizontalInput; float v = verticalInput; bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; if (transform.position.y < -5) { playerAgent.EndEpisode(); } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); yaw += Input.GetAxis("Mouse X") * mouseSensitivity; pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity * 0; currentRotation = Vector3.SmoothDamp(currentRotation, new Vector3(pitch, yaw), ref rotationSmoothVelocity, rotationSmoothTime); transform.eulerAngles = currentRotation; /* yaw += Input.GetAxis("Mouse X") * mouseSensitivity; * pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity * 0; * * currentRotation = Vector3.SmoothDamp(currentRotation, new Vector3(pitch, yaw), ref rotationSmoothVelocity, rotationSmoothTime); * transform.eulerAngles = currentRotation; */ // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: // m_Move = v * Vector3.forward + h * Vector3.right; m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump, yaw); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h; float v; if (useMobileInput) { h = Hinput; v = Vinput; } else { h = Input.GetAxis("Horizontal"); v = Input.GetAxis("Vertical"); crouch = Input.GetKey(KeyCode.C); } // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { int A0 = Interact_Arduino.analogValues.a; //up buttom int A1 = Interact_Arduino.analogValues.b; //right buttom int A2 = Interact_Arduino.analogValues.c; //left buttom // read inputs float h = 0; if (A1 > 512) { h = A1; } else if (A2 > 512) { h -= A2; } //float v = CrossPlatformInputManager.GetAxis("Vertical"); float v = A0; bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // Debug.Log("H:" + Input.GetAxis("Mouse X")); // Debug.Log("cpi:" + CrossPlatformInputManager.GetAxis("Mouse X")); // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); // Debug.Log("h:" + h + " v:" + v); bool fire = CrossPlatformInputManager.GetButtonDown("Fire1"); if (fire) { _animator.SetTrigger("Shoot"); } bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character //however the camera is rotating is where we need to move to if (m_Cam != null) { // calculate camera relative direction to move: //We will only move the camera in the x and z based on user input m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; // Debug.Log("CamForward:" + m_CamForward); m_Move = v * m_CamForward + h * m_Cam.right; // Debug.Log("Move is:" + m_Move); } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Mouse X"); float v = CrossPlatformInputManager.GetAxis("Vertical"); if (v < 0) { v = 0; } bool crouch = Input.GetKey(KeyCode.LeftControl); m_Move = v * gameObject.transform.forward + h * gameObject.transform.right; // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; }
// Fixed update is called in sync with physics private void FixedUpdate() { if (enventoryOn) { h = h - .3f; if (v < 0) { v = v + .3f; if (v > 0) { v = 0; } } else { if (v > 0) { v = v - .3f; if (v < 0) { v = 0; } } } if (h < 0) { h = 0; } } else { h = CrossPlatformInputManager.GetAxis("Horizontal"); v = CrossPlatformInputManager.GetAxis("Vertical"); } v = v + Math.Abs(h / 2); if (v > 1f) { v = 1f; } m_Move = new Vector3(h / 2, 0, v); m_Character.Move(m_Move, m_Jump); }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = Input.GetKey(KeyCode.C); // calculate move direction to pass to character if (m_Cam != null) { // calculate camera relative direction to move: m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * m_Cam.right; } else { // we use world-relative directions in the case of no main camera m_Move = v * Vector3.forward + h * Vector3.right; } #if !MOBILE_INPUT // walk speed multiplier if (Input.GetKey(KeyCode.LeftShift)) { m_Move *= 0.5f; } #endif if (!Input.GetKey(KeyCode.LeftShift)) { // pass all parameters to the character control script rgb.useGravity = true; m_Character.Move(m_Move, crouch, m_Jump); m_Jump = false; } else { rgb.useGravity = false; rgb.velocity = new Vector3(0, 0, 0); if (Input.GetKey(KeyCode.W)) { transform.position = transform.position + Camera.main.transform.forward * cheatSpeed * Time.deltaTime; } } }