Skip to content
Snippets Groups Projects
README.md 1.66 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Huss's avatar
    David Huss committed
    # FPSControl
    
    These two Scripts allow you to implement a simple First-Person Control for Unity. 
    
    
    David Huss's avatar
    David Huss committed
    ### Script 1: Movement
    
    David Huss's avatar
    David Huss committed
    
    This enables the player to change position by walking, running and jumping by pressing the following keys:
    
    - <kbd>W</kbd> or <kbd></kbd>  Moves forwards
    - <kbd>A</kbd> or <kbd></kbd> Moves sidways to the left
    - <kbd>S</kbd> or <kbd></kbd> Moves  backwards
    - <kbd>D</kbd> or <kbd></kbd> Moves  sidways to the right
    
    David Huss's avatar
    David Huss committed
    - <kbd>Space</kbd> Jump (if enabled)
    
    David Huss's avatar
    David Huss committed
    
    ### Script 2: SmoothMouseLook
    
    This allows users to use the mouse for looking around, with seperate sensitivites for Left/Right and Up/Down directions.
    
    ## Setup
    
    ![](images/screenshot.png)
    
    1. Add a Empty with <kbd>Rightclick</kbd> + `Add Empty`. Rename it to something useful (we used `Player`)
    
    David Huss's avatar
    David Huss committed
    2. Make sure the `Main Camera` is at the coordinates `(0, 1.7, 0)` and rotated right and then drag the `Main Camera` onto the `Player`-Empty. This makes `Player` the parent of `Main Camera`
    
    David Huss's avatar
    David Huss committed
    3. Create a Capsule that represents the Player-Body (for collisions and such) with <kbd>Rightclick</kbd> + `3D Object` > `Capsule`.  Drag it onto the `Player`-Empty as well.
    
    Now things should look like in the picture above (highlighted in blue). Next we can add the Scripts.
    
    
    David Huss's avatar
    David Huss committed
    1. Drag the `Movement.cs`-script from the Assets onto the `Player`-Empty
    
    David Huss's avatar
    David Huss committed
    2. Drag the `SmoothMouseLook.cs`-script from the Assets onto the `Player`-Empty. 
    
    David Huss's avatar
    David Huss committed
    
    ## Tweaking
    
    - Adjust the relative positions and sizes of `Player`, `Capsule` and `Main Camera` to change the height of the character and the way rotating the view feels.
    - Adjust the parameters of the scripts
    - Adjust the FOV of the Camera to make it more wide angle or narrow the view down