Simple FPS Controller In 3 Minutes | Unity Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
create a plane called Ground create an empty named player add a camera to the player and set its y position to 1.8 add a character controller to the player and set Center y to one add a new script called player movement remove the sample code add a public float called movement speed and a private character controller reference add an awake method and fetch the character controller add an update method add a private method called handle movement and call it in update create a vector 3 variable called movement to store the horizontal and vertical input axis and make sure Y is set to zero transform the movement Vector to World space multiply it by the movement speed variable call the move method on the character controller and pass in movement multiplied by Delta time you can now move a player create a public float called look sensitivity and a vector 2 called look range add a private camera reference and fetch it in the awake method by calling get component in children add a new method called handle look store the mouse Delta in a vector 2 variable called Delta multiply it by the look sensitivity rotate the transform around the up Axis using Delta X add a private float field called vertical look angle subtracted by the Delta y component in the handle look method and clamp it using the look range field set the camera's oilo angle around the x-axis to the vertical look angle call the handle look method in update lock the cursor by changing the lock State you can now look around add a public float called jump force a key code called jump key and a public float called Ground check radius add a private Vector 3 called velocity and booin called is grounded add a new private method called handle jumping check if the jump key is pressed and is grounded is true increment the Y velocity by the jump force in that case and call the method in update check if we're grounded by calling physics check sphere and passing in the position and ground check radius add a public float called gravity scale create a new private method called handle gravity increment velocity y by the gravity scale multiplied by Delta time we reset velocity y if we're grounded and if velocity Y is negative call the move method again and pass in velocity multiplied by Delta time call handle gravity after to handle movement in update feel free to like And subscribe if you found this tutorial helpful
Info
Channel: GameDevDojo
Views: 79
Rating: undefined out of 5
Keywords: unity, tutorial, fps, controller, 3d, character, player, movement, first person shooter
Id: vo196zSz6Ns
Channel Id: undefined
Length: 3min 8sec (188 seconds)
Published: Wed Dec 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.