Files
decay-grid/Assets/Scripts/Infrastructure/Unity/JumpPadAdapter.cs

25 lines
722 B
C#

using System;
using UnityEngine;
namespace Infrastructure.Unity
{
public class JumpPadAdapter : MonoBehaviour
{
[SerializeField] private float jumpForce = 15f;
[SerializeField] private ParticleSystem jumpVfx;
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<PlayerController>(out var player))
{
var vel = player.Rigidbody.linearVelocity;
vel.y = 0f;
player.Rigidbody.linearVelocity = vel;
player.Rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
if (jumpVfx) jumpVfx.Play();
}
}
}
}