Created
May 7, 2022 03:43
-
-
Save cyberjj999/4c01565b6397a4241e6b890ad81c2cd8 to your computer and use it in GitHub Desktop.
Becoming A Metaverse Developer Article | FixedUpdate() Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void FixedUpdate() | |
{ | |
// If player needs to jump | |
if (toJump) | |
{ | |
// We add a force to the player's rigid body | |
playerRigidBody.AddForce(Vector3.up * 8f, ForceMode.VelocityChange); | |
// Reset jump (so player cannot jump until they are grounded again) | |
toJump = false; | |
} | |
// Modify the transform of our player, moving it by horizontal and vertical input based on our controls | |
transform.position += new Vector3(horizontalInput * 0.05f, 0f, verticalInput * 0.05f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment