// Update is called once per frame void Update() { float horizontal; float vertical; if (useRawAxis) { horizontal = Input.GetAxisRaw(horizontalAxisName); vertical = Input.GetAxisRaw(verticalAxisName); } else { horizontal = Input.GetAxis(horizontalAxisName); vertical = Input.GetAxis(verticalAxisName); } if (Input.GetKeyDown(KeyCode.DownArrow)) { transform.Translate(Vector3.down); } if (pointOfView && pointOfView != transform) { Vector3 forward = Vector3.ProjectOnPlane(pointOfView.forward, groundNormal); Vector3 right = Vector3.Cross(groundNormal, forward); desiredDirection = right * horizontal + forward * vertical; } else { desiredDirection = new Vector3(horizontal, 0, vertical); } if (groundNormal != Vector3.zero) { desiredDirection = Vector3.ProjectOnPlane(desiredDirection, groundNormal); } if (desiredDirection.sqrMagnitude > 1) { desiredDirection = desiredDirection.normalized; } if (!rigidBody) { Vector3 desireMovement = desiredDirection * speed * Time.deltaTime; transform.Translate(desireMovement, Space.World); } if (lookForward && (Input.GetAxisRaw(horizontalAxisName) != 0 || Input.GetAxisRaw(verticalAxisName) != 0)) { lookForward.Update(desiredDirection); } }