feat (root crawler): start the vine grip around the player body when it enter in the slowdown area
This commit is contained in:
@@ -2,15 +2,20 @@ using UnityEngine;
|
||||
|
||||
public class RootCrawler : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Transform target;
|
||||
public float maxHeight;
|
||||
public float crawlingSpeed;
|
||||
|
||||
private float height = 0f;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
height += Time.deltaTime * crawlingSpeed;
|
||||
height = Mathf.Clamp(height, 0f, maxHeight);
|
||||
transform.position = target.position + Vector3.up * height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,15 @@ public class SlowdownArea : MonoBehaviour
|
||||
public float maxSlow;
|
||||
public float slowSpeed;
|
||||
public float timer;
|
||||
|
||||
|
||||
[Header("Root Crawler")]
|
||||
public GameObject rootCrawlerPrefab;
|
||||
|
||||
private float baseJump;
|
||||
private bool isInZone = false;
|
||||
private PlayerMovement player;
|
||||
private PlayerJump jump;
|
||||
private GameObject currentCrawler;
|
||||
|
||||
private void OnTriggerEnter(Collider area)
|
||||
{
|
||||
@@ -22,18 +25,25 @@ public class SlowdownArea : MonoBehaviour
|
||||
baseJump = 5.0f;
|
||||
jump.JumpForce = 1.5f;
|
||||
isInZone = true;
|
||||
if (currentCrawler == null) {
|
||||
currentCrawler = Instantiate(rootCrawlerPrefab, player.transform.position, Quaternion.identity);
|
||||
RootCrawler crawler = currentCrawler.GetComponent<RootCrawler>();
|
||||
crawler.target = player.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider area)
|
||||
{
|
||||
if (area.CompareTag("Player"))
|
||||
{
|
||||
if (area.CompareTag("Player")) {
|
||||
isInZone = false;
|
||||
timer = 0f;
|
||||
player.ApplySlow(1f);
|
||||
player.ApplyAnimationSlow(1f);
|
||||
jump.JumpForce = baseJump;
|
||||
if (currentCrawler != null) {
|
||||
Destroy(currentCrawler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user