feat (root enemies): entrave the jump of the player when in area
This commit is contained in:
@@ -9,14 +9,19 @@ public class SlowdownArea : MonoBehaviour
|
|||||||
public float timer;
|
public float timer;
|
||||||
|
|
||||||
private float baseSpeed;
|
private float baseSpeed;
|
||||||
|
private float baseJump;
|
||||||
private bool isInZone = false;
|
private bool isInZone = false;
|
||||||
private PlayerMovement player;
|
private PlayerMovement player;
|
||||||
|
private PlayerJump jump;
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider area)
|
private void OnTriggerEnter(Collider area)
|
||||||
{
|
{
|
||||||
if (area.CompareTag("Player")){
|
if (area.CompareTag("Player")){
|
||||||
player = area.GetComponent<PlayerMovement>();
|
player = area.GetComponent<PlayerMovement>();
|
||||||
|
jump = area.GetComponent<PlayerJump>();
|
||||||
baseSpeed = player.WalkSpeed;
|
baseSpeed = player.WalkSpeed;
|
||||||
|
baseJump = 5.0f;
|
||||||
|
jump.JumpForce = 1.5f;
|
||||||
isInZone = true;
|
isInZone = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +33,7 @@ public class SlowdownArea : MonoBehaviour
|
|||||||
isInZone = false;
|
isInZone = false;
|
||||||
timer = 0f;
|
timer = 0f;
|
||||||
player.WalkSpeed = baseSpeed;
|
player.WalkSpeed = baseSpeed;
|
||||||
|
jump.JumpForce = baseJump;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +47,5 @@ public class SlowdownArea : MonoBehaviour
|
|||||||
float t = Mathf.Clamp(timer * slowSpeed, 0f, 1f);
|
float t = Mathf.Clamp(timer * slowSpeed, 0f, 1f);
|
||||||
float multiplicator = Mathf.Lerp(1f, maxSlow, t);
|
float multiplicator = Mathf.Lerp(1f, maxSlow, t);
|
||||||
player.WalkSpeed = baseSpeed * multiplicator;
|
player.WalkSpeed = baseSpeed * multiplicator;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user