TheKingsRace/Assets/Scripts/Environment/SlowTerrain.cs
Vincent Wheat a31ac1b79f Slowdown Zones
-Added script for slowing player movement
-Updated Terrain Layouts
2021-12-03 13:22:09 -06:00

27 lines
774 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SlowTerrain : MonoBehaviour
{
//This will need to change to be dynamic (for things like roller skates)
//Also maybe add an isGrounded check?
private void OnTriggerEnter(Collider other)
{
Debug.Log("Slower!");
if (other.gameObject.tag == "Player")
{
other.GetComponent<PlayerStats>().MaxVel = 10.0f; //if player enters trigger slow them down
Debug.Log("Slower");
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "Player")
{
other.GetComponent<PlayerStats>().MaxVel = 25.0f;//if player exits trigger return speed to default
}
}
}