Skip to content

Instantly share code, notes, and snippets.

@cyberjj999
Created May 7, 2022 03:43
Show Gist options
  • Save cyberjj999/4c01565b6397a4241e6b890ad81c2cd8 to your computer and use it in GitHub Desktop.
Save cyberjj999/4c01565b6397a4241e6b890ad81c2cd8 to your computer and use it in GitHub Desktop.
Becoming A Metaverse Developer Article | FixedUpdate() Method
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