Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

FPH ... Get your hands dirty

A topic by hadjer.dev created Jul 28, 2022 Views: 155
Viewing posts 1 to 1
(1 edit) (+1)

#2

I set the environment using the asset you find here then I went with coding 

How to make a First Person Control Game Object ?

Make an empty gameObject and name it FPH and add  the Character Controller Component to it , then drag the camera underneath the game object to be a child gameObject of the FPH , set the position and rotation of the camera to be exactly  the  vector3 you want to have ( the player perspective ) then go to Camera Component and set the field of view parameter to 50 (you go between 40 and 80 )

Till here we have a player with camera , now we have to control the movement and the mouse view since it's a PC game , so I add a script that I called  Mover, here I want to explain a good practice in coding which is namespace , well in a big project where you have to write so many scripts that keep calling each other ,to avoid dependencies we use namespace read more here , and we re going with this practice along the game coding , so the player has a mover , a fighter and health separate scripts (I may add more) , my player is now moving properly it  needs some mouse look configuration that I have to fix   (is moving without balance ) but I can say that it's good enough 

this is only a screenshot of the script , I will share the GitHub repo later