Tip:
Highlight text to annotate it
X
In this tutorial we will see how to create a keyboard-controlled character moving in an environment with static and dynamic obstacles.
Open the project of this tutorial using the Help menu.
Here is a nuclear plant environment.
To add the character,
go to the Entity library, open the 3D Character category,
and drag and drop the Soldier into the scene.
To make him controlled by the keyboard, add a Keyboard to the project.
Double-click the Simulation entity and Synapse will open a graph.
This is the default graph created on every Inscape project.
On the Synapse right panel, you can see the Task library.
Drag and drop the Manipulation / Keyboard / Walk 3D Character task.
Most parameters are already preset, we just need to set a few things:
- The character to control: click on the Soldier character directly in the 3D view
- The subject of the task: select the Keyboard entity
Check the Auto start option to start the task at the beginning of the project.
The character is now controlled by the keyboard.
The next step is to make the camera follow the character while he is walking.
Go back to the Task library and search for 'chase'.
Just like in the Walk task we need to set some parameters:
- The chased object: click on the Soldier character
- The subject of the task: click on the Camera
Like the previous task, check the Auto start option.
Now the camera follows the character but aims at the feet since it is the pivot position of the entity.
We are going to use a hotspot to locate the head of the character.
Use the search field to quickly find the Hotspot entity and drag and drop it on the character's head.
On the Attribute editor, define the GeomParent of the hotspot to attach it to the Soldier.
The hotspot is now following the head of the Soldier.
Finally, replace the parameter of the Chase task to make it follow the hotspot.
The character is now moving with a nice and smooth third person point of view.
The next step is to setup a ground of the scene so that the character will always be grounded,
even when going up or going down the stairs.
For optimization purposes we will use a simplified model to define the collision and ground areas.
You can find the model file using the file explorer in the Data folder.
It is located at Models / Scenes / NuclearPlant / control_center_collisions.v3b
Drag and drop the file in the scene and create a 3DModel entity.
Reset its position to align with the control center.
Now go to the Entity library, use the search field to find the Ground
and drag and drop it into to the scene.
Add an entity to the Entities list of the Ground by right-clicking on the attribute.
Select the collision model. Make sure to select the collision model instead of the control center.
The character can now climb the stairs normally.
The next step is to setup collisions in order to prevent the character from passing through the walls.
Set the DynamicsMode of the Soldier to CollideAndInteract.
Then set the DynamicsMode of the control center collision to CollideOnly
and the DynamicsVolume to MultiBox.
You can see that the character is now blocked by the obstacles defined by the collision model.
Since we do not want to see the collision model during the experiencing,
set the Displayed attribute to False.
Now the character can move in the scene, use the stairs and pass through open doors.
To finish our tutorial, let's add some dynamic obstacles into the scene:
You can find a barrel model file using the file explorer in the Data folder.
It is located at Models / Scenes / NuclearPlant / barrel1.v3b
Drag and drop the file into the scene and create a 3DModel entity.
Set its DynamicsMode to Simulate.
Use the manipulation mode to move the barrel.
Press the Ctrl key while moving the entity in order to clone it and make a pile of barrels.
You now have an interactive character in a dynamic physics world. Have fun!