@@ -7,18 +7,16 @@ namespace Grubs.Pawn;
77[ Title ( "Grubs - Animator" ) , Category ( "Grubs" ) ]
88public sealed class GrubAnimator : Component
99{
10- [ Property ] public required Grub Grub { get ; set ; }
11- [ Property ] public required SkinnedModelRenderer GrubRenderer { get ; set ; }
12- [ Property ] public required GrubPlayerController Controller { get ; set ; }
10+ [ Property ] public Grub Grub { get ; set ; }
11+ [ Property ] public SkinnedModelRenderer GrubRenderer { get ; set ; }
12+ [ Property ] public GrubPlayerController Controller { get ; set ; }
1313
1414 [ Sync ] public bool IsOnJetpack { get ; set ; }
1515 [ Sync ] public float JetpackDir { get ; set ; }
1616
1717 public bool Thinking { get ; set ; }
18-
19- private float _incline ;
20-
21- private Vector3 _looktarget ;
18+ private float Incline { get ; set ; }
19+ private Vector3 LookTarget { get ; set ; }
2220
2321 protected override void OnUpdate ( )
2422 {
@@ -53,9 +51,9 @@ protected override void OnUpdate()
5351 MathX . Lerp ( GrubRenderer . GetFloat ( "lookatweight" ) , shouldLookAt ? 1f : 0f ,
5452 0.2f ) ) ;
5553
56- _looktarget = Vector3 . Lerp ( _looktarget , new Vector3 ( 3f , 4f * - Controller . Facing , 0f ) , Time . Delta * 5f ) ;
54+ LookTarget = Vector3 . Lerp ( LookTarget , new Vector3 ( 3f , 4f * - Controller . Facing , 0f ) , Time . Delta * 5f ) ;
5755
58- GrubRenderer . Set ( "looktarget" , _looktarget ) ;
56+ GrubRenderer . Set ( "looktarget" , LookTarget ) ;
5957
6058 var tr = Scene . Trace
6159 . Ray (
@@ -65,15 +63,16 @@ protected override void OnUpdate()
6563 Controller . WorldPosition + Controller . WorldRotation . Down * 128 )
6664 . IgnoreGameObjectHierarchy ( GameObject )
6765 . Run ( ) ;
68- _incline = MathX . Lerp ( _incline , Controller . WorldRotation . Forward . Angle ( tr . Normal ) - 90f , 0.2f ) ;
69- GrubRenderer . Set ( "incline" , _incline ) ;
66+ Incline = MathX . Lerp ( Incline , Controller . WorldRotation . Forward . Angle ( tr . Normal ) - 90f , 0.2f ) ;
67+ GrubRenderer . Set ( "incline" , Incline ) ;
7068 GrubRenderer . Set ( "backflip_charge" , Controller . BackflipCharge ) ;
7169 GrubRenderer . Set ( "hardfall" , Controller . IsHardFalling ) ;
7270
7371 if ( Grub . Health . IsValid ( ) )
7472 {
7573 GrubRenderer . Set ( "lowhp" , Grub . Health . CurrentHealth <= Grub . Health . MaxHealth / 4f ) ;
7674 GrubRenderer . Set ( "explode" , Grub . Health . DeathInvoked ) ;
75+ GrubRenderer . Set ( "sliding" , Grub . Health . HasBeenDamaged && ! Controller . Velocity . IsNearlyZero ( 2.5f ) ) ;
7776 }
7877 }
7978
0 commit comments