Springboard & FallingPlatform
This commit is contained in:
20
Assets/Content/Scripts/Springboard.cs
Normal file
20
Assets/Content/Scripts/Springboard.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Springboard : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _force = 60;
|
||||
[SerializeField] private float _duration = .4f;
|
||||
[SerializeField] private AnimationCurve _curve = AnimationCurve.EaseInOut(0, 1, 1, 0);
|
||||
[SerializeField] private UnityEvent _onJump;
|
||||
|
||||
void OnTriggerEnter(Collider col)
|
||||
{
|
||||
if (Player.Owner && col.gameObject == Player.Owner.gameObject)
|
||||
{
|
||||
Debug.Log("Player triggered springboard");
|
||||
Player.Owner.AddExtraForce(Vector3.up * _force, true, _duration, _curve);
|
||||
_onJump?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user