A simple tutorial for making character controller move with WASD key.
- Create new Scene
- Create ‘Plane‘ and set position to (0, 0, 0)
- Create ‘Capsule‘ and set position to (0, 1, 0)
- Add ‘Character Controller‘ Components to the Capsule object.
- Add ‘uNodeRuntime‘ Components to the Capsule object.
- Find and Select ‘Main Camera‘ object in hierarchy then change position to (0, 5, -8) and rotation to (30, 0, 0)
- The final scene will look like this:
Making Character Controller Move
- Select Capsule object and Open ‘uNode Editor‘
- Add ‘Update‘ function
The Update function will be called every frame, this allow us to call node every frame which will update character movement.
- Select ‘Update‘ function and Add new local variable with type : Vector3
- Rename new variable by right click it and select ‘Rename‘ and change name to ‘input‘ and hit ‘Enter‘ or click ‘Apply‘ button.
- Follow the video bellow to create nodes for receive player input.
This will receive player input and store it to ‘input‘ variable which we want to use to move the character.
- Follow the video bellow to make character move.
Now when we play the game we can move the character by WASD key but the moves is slow.
Follow the next steps to making character move with desired speed.
Making Character move with desired speed.
- Add new variable with type : ‘float‘ with name ‘speed‘ and change its value ex: 5
- Add new node for get ‘speed‘ variable.
- Add new ‘Multiply‘ node connect first pin to ‘Time.deltaTime‘ node and second to ‘speed‘ node.
- Reconnect pin from another ‘Multiply‘ node that target ‘Time.deltaTime‘ node to new ‘Multiply‘ node.
- The complete steps should like this: