RotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit) RotationX += -Input.GetAxis("Mouse Y") * 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 Note: I’m using Unity 2019.3.9f1 but this tutorial should work for any other version as well. If (Input.GetButton("Jump") & canMove & characterController.isGrounded) Give your project a name (Unity FPS Tutorial in my case, but you can name it however you want) Select the destination for your project. MoveDirection = (forward * curSpeedX) + (right * curSpeedY) Vector3 right = transform.TransformDirection(Vector3.right) īool isRunning = Input.GetKey(Ke圜ode.LeftShift) įloat curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0 įloat curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0 įloat movementDirectionY = moveDirection.y Vector3 forward = transform.TransformDirection(Vector3.forward) Landing on a platform is a test of the player’s hand eye coordination as well as their skill at controlling the player. Platforms create a target for players to aim for when traversing the level. Moving platforms are a staple in any platformer. We are grounded, so recalculate move direction based on axes Unity Create a Moving Platform the Player Character Can Stand On Moving Platforms In Unity. Public class SC_FPSController : MonoBehaviourĬursor.lockState = CursorLockMode.Locked UNITY 3D PLAYER CONTROLLER CODE
0 Comments
Leave a Reply. |
AuthorHolly ArchivesCategories |