Jump to content

* * * * *
Contents


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

Attached Image: 1.PNG

Creating a Character Controller

The green figure you see inside the scene is the FPSplayer prefab.

Attached Image: 2.PNG

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.

Attached Image: 3.JPG

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.

Attached Image: 4.JPG

Testing 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.

Attached Image: 5.jpg

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.

Attached Image: 6.jpg

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.

Attached Image: 7.jpg

Press escape to go 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.

Attached Image: 8.jpg

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

Attached Image: 5.png

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'.

Attached Image: 10.jpg


1 Comments

when I click run or debug run then after a few seconds in *advanced first person shooter* it crashes not the program but just the run or debug run any help?