Leadwerks Game Engine

Leadwerks Game Engine

Not enough ratings
Tutorial - FPS controller
By Aggror and 1 collaborators
Leadwerks has a build in Character controller. We can use this character controller to simply and very quickly walk around in a level that you have created.
   
Award
Favorite
Favorited
Unfavorite
Intro
Leadwerks has a build in Character controller. We can use this character controller to simply and very quickly walk around in a level that you have created. Open up the FPS controller map. Press F12 to maximize the perspective viewport so that you can have a look at the level overview



Setting up character controller
The green puppet you see inside the scene is the FPSplayer prefab.



This prefab has a character controller script attached and is ready for use. Go to scene tab and locate the player. Select the player object in your scene view and go to scrip tab. As you can see the Fpsplayer.lua script is attached. You can change the script properties to let the player behave in the way you want. For instance; you can change the jump value or the speed of the camera rotation.



If you go to the physics tab you will notice a few values that are being. The physics mode is set to " character controller" , the mass = '10' and the collision type is set to " character" . If you want to make your own character controller inside the editor, then you need to set these properties, otherwise the character controller will not word.


Testing out the scene
Let's try out the scene. The first thing you will notice is that the green character model is no longer visible. This is handled via the attached script.

Step height
The character controller automatically steps on low obstacles like a sidewalk. In front of us we see 3 CSG blocks, each with their own height. When the step height is too heigh, the player can only try jumping to get on top of it. The two blocks on the left are low enough for the character controller to automatically hop on top of them.



We then proceed to the stairs. The character will walk up these stairs while using the auto step height and camera smoothing.

Jumping
We then face the jumping par course. In order to jump you need to press the ' Space' key. If you are not fast enough you might not be able to cross a gap. You can run by pressing 'Shift.



Slopes
The next challenge of the scene are the slops. The character controller can walk automatically walk on slopes that have an angle of 45 degrees or lower. If you would walk on to a steep slope, you slide down automatically.



Press escape to ga back to editor.
Creating prefabs
Go to prefab folder. Drag in the fpsplayer prefabs. Its facing the wrong way. Rotate the player by using the Rotate Y button.



Go to scene tab and change values like the jump value. You will be notitfied that the connection will be lost.



You can save the character with all settings as a new prefab. In the scene view you can right click on your character controller and click on ' save as prefab'.

3 Comments
den24 26 Nov, 2023 @ 3:30pm 
thanks!
crim 1 Jul, 2016 @ 8:08pm 
there's no FPSPlayer prefab for me
odlaw 16 Sep, 2015 @ 9:17pm 
how do I actually pick up/ spawn in with a weapon?