Movement¶
This is a method that is called on every LateUpdate where the player isn't dashing (if they were, the movement logic would be overriden by DashBehavior).
It handles movement logic using the information gathered from Update's movement inputs processing, but it only does if all of the following conditions are true:
- We aren't in an instance.
pause - We aren't in an instance.
minipause - We aren't in instance.
inevent - The message lock is released
- entity.
rigidexists
There are 2 possible logic:
- If the -2 input (any movement input) is held, movement logic happens
- Otherwise (no movement input are held), the stop logic happens
Movement logic¶
This only happens when any movement inputs is held:
- If entity.
hitwallis false:- The
spdvalue is determined and their x/z components will be set to the entity.rigidx/z velocity (the y velocity is unchanged). The first cases below that applies is selected and its matchingspdvalue will be used:- The player is
flying:spdislastdelta* entity.speed/ 2.0 - The player is
diggingor is in ashield:spdislastdelta* entity.speed/ 1.5 - MainManager.
analogis 0 (OFF):spdislastdelta* entity.speed - None of the above cases applies:
spdiswalkdelta
- The player is
- If the player isn't
flying, entity.animstate is set to 1 (Walk)
- The
- Otherwise:
- StopMoving is called on the entity with a targetstate of 1 (
Walk)
- StopMoving is called on the entity with a targetstate of 1 (
- If the down input is held:
- instance.
camspeedis set to a lerp from the existing one to 0.25 with a factor of TieFramerate(0.01) - If entity.
hitwallis false:- instance.
camoffset2is set to a lerp from the existing one to -CamDir.forward.normalized * 1.25 with a factor of TieFramerate(0.025)
- instance.
- Otherwise (entity.
hitwallis true):- ReturnOffset called which sets instance.
camoffset2to a lerp from the existing one to Vector3.zero with a factor of TieFramerate(0.01)
- ReturnOffset called which sets instance.
- instance.
- Otherwise (the down input isn't held):
- If instance.
changecamspeedis false, instance.camspeedis set to 0.1 - ReturnOffset called which sets instance.
camoffset2to a lerp from the existing one to Vector3.zero with a factor of TieFramerate(0.01)
- If instance.
What happens next relate to the movement sound and it depends if the player is in a submarine or not. Only one of the 2 cases applies.
submarine sonar sound¶
It only applies if digging is true (the player is underwater) and that Sonar isn't playing on entity.sound. If these conditions are fufilled, Sonar is played on entity.sound without loop at 0.75 volume.
No submarine footstep sound¶
First, entity.sound is set to not loop.
From there, the footstep sound logic only applies if all of the following conditions are fufilled:
- entity is
onground - The player isn't
digging - entity.
soundisn't playing
If all of the above are fufilled, footstep is decreased by framestep.
From there, if footstep reached 0.0 or below, the Footstep sound plays on the entity with footstep being set to 7.5. This means that as long as the player keeps moving, there will be a sound every 7.5 frames of movement. This resets when movement is stopped as explained in the stopping logic below.
Stop logic¶
This only happens when no movement input is held:
footstepis reset to 0.0 (reset the timer for the sound when moving)- ForceHitWall called on the entity
- Movement is stopped with a method that depends on if the player is in a
submarine:- If it is, StopMoving is called on the entity with a targetstate of 0 (
Idle) - If it's not, entity.
rigidvelocity is lerped from the existing on to Vector3.zero with a factor of TieFramerate(0.025)
- If it is, StopMoving is called on the entity with a targetstate of 0 (
- ReturnOffset called which sets instance.
camoffset2to a lerp from the existing one to Vector3.zero with a factor of TieFramerate(0.01)