PlayerControl FixedUpdate¶
What's contained here is miscellaneous updates, but there's one of 3 update types that can happen here (the first one is chosen):
startdig
is true while the player isn't in asubmarine
meaning thedigging
state needs to be updated- The player is in a
submarine
and entity.model
exists meaning thesubmarine
state needs to be updated - Neither of the cases above applies meaning the entity.
sprite
local position needs to be progressively restored
digging
update¶
- entity.
sprite
local y position is lerped from the existing one to -2.0 with a factor of 0.03 lockkeys
is set to true if the player isn't fullydigging
yet and to false if it is. This essentially locks most inputs processing fromstartdig
to fullydigging
- If entity.
sprite
local y position reached -1.5 or lower:digging
is set to true
- Otherwise (still in
startdig
):- StopMoving called on the entity with its current animstate as the targetstate
- If no sound is playing on entity.
sound
:- If the player is fully
digging
, theDigging
sound is played on loop on the entity with a volume of 0.8
- If the player is fully
- Otherwise (a sound is already playing on entity.
sound
):- entity.
sound
.pitch is set to a value that depends ondelta
.magnitude (meaning if there's enough movement):- > 0.1: 1.1 pitch
- \<= 0.1: 0.95 pitch
- entity.
submarine
update¶
- If we're not in instance.
inevent
, entity.emoticonoffset
is set to Vector3.up - The entity gets some adjustements:
flip
is set to falseoverrideflip
set to truesprite
angles zeroed outsprite
scale set to Vector3.zeromodel
local y position set to a lerp from the existing one to Sin(Time.time * 3.0) * 0.15 (unlessdigging
is true where it's -0.5 instead) with a factor of 0.05model
.extra[1]
(the telescope) local position is set to (0.575, 0.0,Z
) whereZ
is determined by a lerp from the existing local z position to 0.5 (4.0 instead ifdigging
is true) with a factor of 0.025 (0.5 is actually the normal position of where the telescope should be)model
.extra[0]
(the propeller) is set to rotate in x by 15.0 * entity.rigid
velocity magnitudemodel
angles are updated:- x: Always -90.0
- y: LerpAngle from the existing y angle to entity.
detect
y angle - 90.0 with a factor of 0.1 (1.0 instead if instance.inevent
). Essentially, it aligns the y angles to where the player is heading with a bit of delay unless we are instance.inevent
where it instantly aligns - z: Sin(Time.time * 3.0) * (entity.
rigid
velocity magnitude / 2.0) which makes the submarine wave slightly periodically
entity.sprite
local position restore¶
The only thing that happens in this update is the entity.sprite
local position is lerped from the existing one to Vector3.zero with a factor of 0.17.