There's more...

In the provided example, we created our own script for moving the character using a Rigidbody component. You can find the script in the Shared scripts directory. It is called SimpleMove.cs. To make your character move:

  1. Add a collider component (we use a Sphere Collider in the example) and a Rigidbody component to it.
  2. Create a zero friction Physics Material and assign it to the collider component.
  3. Set the Rigidbody component Constraints to Freeze Rotation in the XY, and Z axes.
  4. Create an empty game object, position it around 0.2 units above the character's feet, and parent it to the character. Name it GroundCheck for clarity.
  1. Attach the script to the character's game object. Attach the GroundCheck game object to the Ground Check Transform field of the Simple Move script component.
  2. If you want your character to have an animation, create an Animator Controller with float Speedbool Ground, and Trigger Jump parameters. Prepare idlewalk, and jump animations. Idle and walk should be looped, jump should end in the air.
  3. Create a transition between idle and run using the Speed parameter with the Speed > 0.1 condition.
  4. Create a transition between run and idle using the Speed parameter with the Speed < 0.1 condition.
  5. Create transitions from run and idle to jump using the Jump trigger parameter.
  6. Create transitions from jump to run and idle using the Ground and Speed parameters. Conditions should check if Ground is true and if Speed < 0.1 (transition to idle) or Speed > 0.1 (transition to run).
  7. Attach the Animator Controller to your character.
  8. Parent the game camera to your character or use the provided CameraFollow.cs script found in the Shared scripts directory. You can also use one of the camera scripts found in Unity's Standard Assets.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.28.126