Skip to content

A 3D Unity fps movement controller using rigidbody physics. Made to be simple to setup and easy to edit.

License

Notifications You must be signed in to change notification settings

B0N3head/unity-fps-movement-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Fps Movement Controller

A simple to setup and easy to edit unity fps controller using rigidbody movement in c#. Almost every variable used in this player controller is customisable and accessible from the inspector (No programing required).

Feel free to use it in your own projects if you'd like!

Trello Link to follow the progress of the next update 🎉

Features

  • Fully momentum based movement
  • Customizable speeds for:
    • Walking
    • Sprinting
    • Crouching
    • Air speed
  • Jumping
  • Crouching
  • Inspector
    • Simple named vars (easy to understand)
    • All vars contain quick descriptions within tool tips
    • GUI based layer choice (choosing ground layer)
  • Camera
    • Variable smoothing of the camera
    • Clamped look directions
    • Variable sensitivity
    • Cursor lock/unlock
  • Configurable keys: (See controls)
    • Jumping
    • Crouching
    • Sprinting
    • Lock/Unlocking mouse
  • Fast auto setup in one button button click
    • Creates and sets up rigidbody
    • Creates and sets up camera
    • Sets unity physics gravity to -19
      • Ask user if they want to set custom gravity
    • Ask and create "Ground" tag if it does not exist

Visual examples

Variable Jump Height & Jump Cooldown Smoothed lerp Crouch vs Non-Smothed Coyote Time (Slowed & Exaggerated)

Controls

This script is currently setup with these default controls. These are all configurable from the editor. (don't require any coding)

Key(s) Action
WSAD Simple character movement
Space Jump
Shift Sprint
Z* Crouch
Q Lock/Unlock Mouse
*CTRL creates issues when testing in editor so Z is used (ctrl + most keys = will run unity hotkey)

How to setup the character

  1. Download and add the files to your assets folder

  1. Add a capsule to your scene

  1. Add the Player Movement script through Component -> Player Movement and Camera Controller

  1. Click the "Setup Player & World" button (I have not updated the old images yet, tho everything is in the same location)

Done, you should now be left with something similar to the bellow

One more thing

Please make sure that whatever the player is intended to stand/jump onto or from is set to the Ground tag.

When setting up the script, you will be prompted to let the script create the tag for you (I have not and prob wont create an algorythm/ai to detect what should and shouldn't be ground... so you will have to manually lable what should be ground).