Attach SC_TPSController script to "Player" Object (You will notice that it also added another component called Character Controller, change its center value to (0, 1, 0)).PlayerCameraParent.localRotation = Quaternion.Euler(rotation.x, 0, 0) Rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit) Rotation.y += Input.GetAxis("Mouse X") * lookSpeed MoveDirection.y -= gravity * ltaTime ĬharacterController.Move(moveDirection * ltaTime) This is because gravity should be applied when the moveDirection is multiplied by deltaTime). Gravity is multiplied by deltaTime twice (once here, and once below MoveDirection = (forward * curSpeedX) + (right * curSpeedY) Vector3 right = transform.TransformDirection(Vector3.right) įloat curSpeedX = canMove ? speed * Input.GetAxis("Vertical") : 0 įloat curSpeedY = canMove ? speed * Input.GetAxis("Horizontal") : 0 Vector3 forward = transform.TransformDirection(Vector3.forward) We are grounded, so recalculate move direction based on axes Public class SC_TPSController : MonoBehaviour
0 Comments
Leave a Reply. |