Physics Based Character Controller in Unity

--

The objective is to move the Player using controller.Move(), but also to create other options like jumpHeight and gravity to be modified in inspector as desired

  • Create a Player script
  • Declare a CharacterController controller. Assign it in Start()

direction: increase the player’s position in the x axis with the inputH value.
For example, if inputH is 1, increase 1 (move it to the right).
If inputH is -1, move it to the left.

Let’s set the gravity value to 1.

After pressing the space key, the yVelocityvalue will be the jumpHeight value (20) in the first frame. Later, this value will be decreasing -1

The player won’t set it’s position as the velocity.y value (20) immediately. Read this blog for more info

Now we have a customizable controller

--

--

No responses yet