similar to Custom Gravity and Player Movement (Ongoing project) , @Entity404 will (hopefully) love this post as it has the custom movement (+plus effects) for the player that he was after
@Delightex_Team i think you guys would like this, also would be appreciated if you could take a look into this and tell me what you think about it.
(link to project is at the bottom if you want to take a look, there is also a summary there to get a little info on this if you don’t want to read the whole post)
KEYBOARD ONLY
(however I may create a non-keyboard version in the future)
Custom Movement & Effects Controller
Made and built by BlackTip_Codes_Stuff
Hey everyone!
I have spent well over 15 hours across multiple days making, testing, and improving a custom movement and camera-effects controller for Delightex TypeScript.
The main goal of this project was to make a movement controller that feels more polished than the default movement, while still being easy for beginners to customise.
You do not need much TypeScript knowledge to use this. Most of the things you may want to change are located at the top of the script inside the SETTINGS section. This includes movement speeds, controls, stamina, FOV, camera effects, sound volumes, and more.
If you are not trying to add new features or remake parts of the controller, you should not need to change the main controller code.
What is included?
Custom movement
This controller includes its own movement system with:
-
WASD movement
-
Camera-relative movement (this includes FOV changes based on speed)
-
Walking
-
Sprinting
-
Acceleration
-
Deceleration
-
Diagonal movement
-
Custom movement speeds
-
view bobbing
-
camera sway
-
audio for sprinting, walking, and jumping
-
and a couple extra subtle effects and smoothing that make it overall better
The player does not instantly reach full speed. The controller gradually accelerates the player and also gradually slows the player down when movement stops.
This makes the movement feel less stiff and robotic.
The walking and sprinting speeds can be changed in the SETTINGS section:
let walkSpeed: number = 3;
let sprintSpeed: number = 6;
You can change these numbers without needing to understand the rest of the movement code.
Sprinting
Sprinting is toggle-based by default.
Press Q to turn sprinting on or off.
Sprinting includes:
-
Increased movement speed
-
Increased camera FOV
-
Faster footsteps
-
A subtle sprint camera effect
-
Stamina usage
The sprint speed can be changed here:
let sprintSpeed: number = 6;
The sprint camera effect, sprint FOV, and sprint footstep speed can also be changed separately in the SETTINGS section.
Stamina system
The controller includes a stamina system that is used while sprinting.
While sprinting, stamina drains over time. When you are not sprinting, stamina slowly regenerates.
The main stamina settings are:
let maxStamina: number = 100;
let staminaDrain: number = 20;
let staminaRegen: number = 10;
The controller also includes a stamina bar made from 10 separate scene items.
Each stamina bar piece turns off depending on how much stamina is left. For example, if the player has around 50% stamina, around half of the stamina bar pieces will still be active.
The stamina bar items are named:
StaminaBar1
StaminaBar2
StaminaBar3
StaminaBar4
StaminaBar5
StaminaBar6
StaminaBar7
StaminaBar8
StaminaBar9
StaminaBar10
You can rename these items if you also change their names in the SETTINGS section.
There is also a low-stamina camera effect. When stamina goes below the chosen threshold, the camera starts to sway more. The lower the stamina gets, the stronger the effect becomes.
let lowStaminaThreshold: number = 30;
let lowStaminaSwayAmount: number = 0.015;
let lowStaminaSwaySmoothness: number = 5;
Custom jumping
Jumping uses custom vertical velocity and gravity.
The jump strength can be changed here:
let jumpSpeed: number = 7;
The gravity can also be changed:
let gravity: number = -9.8;
I recommend leaving the gravity at its default value unless you know how the jump system works, but you can change the jump speed if you want the player to jump higher or lower.
The jump also plays a sound and includes a small camera effect.
Camera effects
The controller includes multiple camera effects that work together.
View bobbing
While the player is moving, the camera gently moves to create a head-bobbing effect.
let bobAmount: number = 0.05;
let bobSpeed: number = 8;
bobAmount controls how much the camera moves.
bobSpeed controls how quickly the camera movement happens.
Camera sway
The camera also slightly rotates from side to side while moving.
let swayAmount: number = 0.008;
This is kept quite low by default because too much camera movement can become distracting.
Low-stamina camera effect
When the player’s stamina gets low, the camera starts to sway more.
This gives the player a visual warning that their stamina is running out, instead of only relying on the stamina bar.
Sprint camera effect
While sprinting, the camera has a subtle extra movement effect.
This works together with the increased FOV and faster footsteps to make sprinting feel different from normal walking.
let sprintEffectAmount: number = 0.025;
let sprintEffectSmoothness: number = 8;
It is recommended that you do not change this too much, but it is still available in the SETTINGS section if you want to adjust it.
Jump camera effect
Jumping also moves the camera slightly.
let jumpEffectAmount: number = 0.12;
let jumpEffectSmoothness: number = 8;
This only changes the camera effect. It does not change the actual jump physics.
Sound system
The controller includes custom sound support using the Delightex Sound API.
It currently includes:
-
Three different footstep sounds
-
One jump sound
Footsteps
There are three footstep sound assets in the controller.
Whenever a footstep plays, the controller randomly chooses one of the three sounds. This helps stop every footstep from sounding exactly the same.
The footstep timing can be changed here:
let footstepInterval: number = 0.45;
let sprintFootstepMultiplier: number = 0.7;
The sprint multiplier controls how quickly footsteps happen while sprinting.
A value lower than 1 makes the sprint footsteps happen faster.
A value higher than 1 makes them happen slower.
The footstep volume can be changed here:
let footstepVolume: number = 0.5;
Jump sound
The controller plays a sound whenever the player jumps.
The jump sound volume can be changed separately:
let jumpSoundVolume: number = 0.5;
Using your own sounds
You can replace the sound assets with your own sounds.
Near the top of the script, you will find the sound asset section:
const footstepSound1 = Sound.load(
"YOUR SOUND ID HERE"
);
To use your own sound:
-
Upload your sound to Delightex.
-
Open the sound options.
-
Select Copy ID.
-
Remove the existing sound ID.
-
Paste your own sound ID into the script.
You can do this for all three footstep sounds and the jump sound.
For the best result, each footstep sound should contain only one footstep instead of multiple footsteps in one audio file.
Beginner-friendly settings
One of the main goals of this project was to make the controller easy to customise.
The SETTINGS section includes:
-
Scene item names
-
Keybinds
-
Walking speed
-
Sprinting speed
-
Acceleration
-
Deceleration
-
Jump strength
-
Gravity
-
Maximum stamina
-
Stamina drain
-
Stamina regeneration
-
Normal FOV
-
Sprint FOV
-
View bobbing
-
Camera sway
-
Low-stamina effects
-
Sprint camera effects
-
Jump camera effects
-
Footstep timing
-
Sound volumes
For example, if you want to change the sprinting speed, you only need to change this:
let sprintSpeed: number = 6;
to something like this:
let sprintSpeed: number = 10;
You do not need to understand the entire controller just to change a setting.
The controls can also be changed at the top of the script:
const forwardKey = "w";
const backwardKey = "s";
const leftKey = "a";
const rightKey = "d";
const jumpKey = "space";
const sprintKey = "q";
Please note that control, shift, and alt do not work as keybinds.
The available keybinds can be found here:
https://docs.edu.delightex.com/typescript/api/public/modules/Input.html
Scene setup
The controller expects certain items to exist in the scene.
The default item names are:
PlayerBody - (in development)
Camera
StaminaBar1
StaminaBar2
StaminaBar3
StaminaBar4
StaminaBar5
StaminaBar6
StaminaBar7
StaminaBar8
StaminaBar9
StaminaBar10
If you rename any of these items, you also need to change the matching name in the SETTINGS section.
The PlayerBody is added to the camera’s collision filter so the camera does not collide with the visible player body. (currently the player body is an unused asset as im working on adding a player body with full animations)
How the code is organised
The controller is split into different sections so it is easier to understand and edit.
The main sections are:
SETTINGS
SOUND ASSETS
INTERNAL CONTROLLER VARIABLES
INTERNAL FUNCTIONS
INPUT
MAIN CONTROLLER LOOP
The SETTINGS section is where most users should make their changes.
The SOUND ASSETS section is where you can replace the footstep and jump sounds.
The INTERNAL sections contain the variables and functions used by the controller.
The INPUT section connects the keybinds to the movement, jumping, and sprinting.
The MAIN CONTROLLER LOOP is where the controller updates the movement, stamina, camera effects, jumping, footsteps, and everything else.
If you are only changing settings, you should not need to edit the main controller loop.
However, if you want to add features or make your own proper version of the controller, the main loop is the most important part to study.
AI disclaimer
AI was used during this project to help streamline the development, fix bugs, clean up parts of the code, and polish the final controller.
The fundamental code, ideas, testing, settings, and development were still done by me.
I spent well over 15 hours across multiple days working on this and testing how everything worked in-game.
Usage and credit
Feel free to use this controller in your own Delightex games.
The only thing I ask is that you credit my username in your game’s description:
BlackTip_Codes_Stuff
I have spent well over 15 hours making this so people can use it in their own games, so I would really appreciate it if you gave credit when using it.
That is all I ask of you.
Final thoughts
This started as a custom movement experiment and eventually became a full movement and camera-effects controller.
It now includes:
-
Custom WASD movement
-
Acceleration and deceleration
-
Toggle sprinting
-
Stamina
-
A 10-piece stamina bar
-
Custom jumping
-
Sprint FOV
-
View bobbing
-
Camera sway
-
Low-stamina camera effects
-
Sprint camera effects
-
Jump camera effects
-
Randomised footsteps
-
Custom jump sounds
-
Beginner-friendly settings
I tried to make the controller easy to use for people who may not know much TypeScript yet, while still keeping the code organised enough for people who want to learn from it or add their own features.
Hopefully this is useful for anyone making a game where movement and effects can add a lot of life
Have fun making your games! ![]()
— BlackTip_Codes_Stuff
Summary:
A reusable first-person movement controller made with Delightex TypeScript.
Includes custom WASD movement, acceleration and deceleration, toggle sprinting, stamina, a 10-piece stamina bar, custom jumping, sprint FOV, camera bobbing, camera sway, low-stamina effects, sprint camera effects, jump camera effects, and randomised footstep sounds.
The controller is designed to be beginner-friendly. Most settings are organised at the top of the script, so you can change the movement speeds, keybinds, FOV, stamina, camera effects, and sound volumes without needing to understand the entire controller.
AI was used to help fix bugs, streamline parts of the project, and polish the code. The fundamental code, ideas, testing, and development were still done by me.
Feel free to use this in your own Delightex games.
All I ask is that you credit BlackTip_Codes_Stuff in your game’s description.
Anyways, thats about as well as i could summarise it. Enjoy!
video demonstration: https://youtu.be/kHqDg9-fjMQ
thank you for reading! link to project is here: Delightex Edu :: Custom Movement & Effects for Players!
would love to hear you guys thoughts on it!
- YESSS
- sure
- Maybe
- Ehhh
- No
If you find a bug, want me to add a feature, or just have a general request relating to typescript, reply to the post and I am happy to help!