28 lines
865 B
C#
28 lines
865 B
C#
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace BlueWaterProject
|
|
{
|
|
public class Cannon : MonoBehaviour
|
|
{
|
|
[SerializeField] private GameObject projectileObj;
|
|
[SerializeField] private Transform firePos;
|
|
|
|
public float speed = 2000f;
|
|
|
|
[Button("셋팅 초기화")]
|
|
private void Init()
|
|
{
|
|
projectileObj = Utils.LoadFromFolder<GameObject>("Assets/05.Prefabs/Particles/GrenadeFire", "GrenadeFireOBJ", ".prefab");
|
|
firePos = transform.Find("FirePos");
|
|
}
|
|
|
|
public void Fire(float chargingGauge)
|
|
{
|
|
var projectile = Instantiate(projectileObj, firePos.position, Quaternion.identity);
|
|
projectile.GetComponent<Rigidbody>().AddForce(transform.forward * (chargingGauge * speed));
|
|
}
|
|
}
|
|
}
|