Post Port Pseudocode Movement - Milowan/WarChildPort GitHub Wiki
float movSpeed
float sensitivity
float pitch
float maxPitch
float yaw
float jumpSpeed
bool jumping
Camera playerCamera
Player player
float minSpeedfloat maxSpeed
int maxJumps
int jumpCount
bool sliding
bool sprinting
Set jumping to false.
Set jumpSpeed to 10.
Set maxPitch to 30.
Set sensitivity to 5.
Set pitch to 0.
Set yaw to 0.
Set player to the player object.
Set movSpeed to the player object's speed variable.
Set playerCamera to the main camera object.
Set jumpCount to 0.Set maxJumps to 2.
Local Vector3 set:
x to Horizontal input axis multiplied by movSpeed,
y to zero,
z to Vertical input axis multiplied by movSpeed.
Set yaw += MouseX input axis multiplied by sensitivity.
Set pitch -= MouseY input axis multiplied by half of sensitivity.
If pitch is greater than maxPitch,
Set pitch to maxPitch.
If pitch is less than negative maxPitch,
Set pitch to negative maxPitch.
Set this object's transform-rotation to (0, yaw, 0). turns player left and right
Execute player object's UpdateWeapon with parameters: pitch, yaw.
Set the playerCamera object's transform-rotation to (pitch, yaw, 0). allows the camera to also look up and down
On button-down SHIFT ("Sprint"),
Execute the Sprint function.
On button-up SHIFT ("Sprint"),
Execute the StopSprint function.
If the player presses SPACE ("Jump"),
If jumpCount < maxJumps,
Execute the Jump function.
If the player presses CTRL ("Slide"),
If sprinting is true or if jumping is true,
Execute the Slide function.
If the player presses LMB ("Fire1"),
Execute the player object's PullTrigger function.
On button-down RMB ("AIM"),
Execute the Aim function.
On button-up RMB ("Aim"),
Execute the UnAim function.
If function parameter is terrain,
Set jumping to false.
Set jumpCount to 0.
Set jumping to true.
Increment jumpCount.
If sliding is true,
Add force UP and FORWARD on the player.
Else,
Add force UP on the player.
Set sliding to true.
If jumping is true,
Add force FORWARD and DOWN on the player.
Else,
Add force FORWARD on the player.
If jumping is true,
Slow down the player's movement on all 3 axis
Aim down the sights (however we plan to do that).
Undo the ADS logic.
Set movSpeed to maxSpeed
Set movSpeed to minSpeed