refactor (slowndow): create a function in movement script to apply the slowdown 'keep the logic'
This commit is contained in:
@@ -8,7 +8,7 @@ public class SlowdownArea : MonoBehaviour
|
||||
public float slowSpeed;
|
||||
public float timer;
|
||||
|
||||
private float baseSpeed;
|
||||
|
||||
private float baseJump;
|
||||
private bool isInZone = false;
|
||||
private PlayerMovement player;
|
||||
@@ -19,7 +19,6 @@ public class SlowdownArea : MonoBehaviour
|
||||
if (area.CompareTag("Player")){
|
||||
player = area.GetComponent<PlayerMovement>();
|
||||
jump = area.GetComponent<PlayerJump>();
|
||||
baseSpeed = player.WalkSpeed;
|
||||
baseJump = 5.0f;
|
||||
jump.JumpForce = 1.5f;
|
||||
isInZone = true;
|
||||
@@ -32,7 +31,7 @@ public class SlowdownArea : MonoBehaviour
|
||||
{
|
||||
isInZone = false;
|
||||
timer = 0f;
|
||||
player.WalkSpeed = baseSpeed;
|
||||
player.ApplySlow(1f);
|
||||
jump.JumpForce = baseJump;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +45,6 @@ public class SlowdownArea : MonoBehaviour
|
||||
timer += Time.deltaTime;
|
||||
float t = Mathf.Clamp(timer * slowSpeed, 0f, 1f);
|
||||
float multiplicator = Mathf.Lerp(1f, maxSlow, t);
|
||||
player.WalkSpeed = baseSpeed * multiplicator;
|
||||
player.ApplySlow(multiplicator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user