Files
FallBots/Assets/Content/Scripts/Springboard.cs

19 lines
483 B
C#

using UnityEngine;
using UnityEngine.Events;
public class Springboard : MonoBehaviour
{
[SerializeField] private float _force = 20;
[SerializeField] private UnityEvent _onJump;
void OnTriggerEnter(Collider col)
{
if (Player.Instance && col.gameObject == Player.Instance.gameObject)
{
Debug.Log("Player triggered springboard");
Player.Instance.AddForce(transform.up * _force);
_onJump?.Invoke();
}
}
}