Add JumpPad feature with prefab and adapter implementation
This commit is contained in:
25
Assets/Scripts/Infrastructure/Unity/JumpPadAdapter.cs
Normal file
25
Assets/Scripts/Infrastructure/Unity/JumpPadAdapter.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user