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
Creating a Character ControllerThe green figure 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 the SceneLet'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 HeightThe 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.
JumpingWe 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.
SlopesThe 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 go back to editor.
Creating PrefabsGo 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 notified 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'.