38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
![]() |
using System;
|
||
|
using Blobcreate.ProjectileToolkit;
|
||
|
using UnityEngine;
|
||
|
|
||
|
// ReSharper disable once CheckNamespace
|
||
|
namespace BlueWaterProject
|
||
|
{
|
||
|
public class Canon : MonoBehaviour
|
||
|
{
|
||
|
public float power;
|
||
|
public float reloadTime;
|
||
|
public GameObject radarTargetUI;
|
||
|
|
||
|
public Rigidbody projectilePrefab;
|
||
|
public Transform launchPoint;
|
||
|
public float timeOfFlight = 1f;
|
||
|
public Transform predictedPos;
|
||
|
|
||
|
private void Init()
|
||
|
{
|
||
|
projectilePrefab = DataManager.Inst.grenadeFire.GetComponent<Rigidbody>();
|
||
|
launchPoint = transform.Find("FirePoint");
|
||
|
}
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
Init();
|
||
|
}
|
||
|
|
||
|
public void Fire()
|
||
|
{
|
||
|
var myRigid = Instantiate(projectilePrefab, launchPoint.position, launchPoint.rotation);
|
||
|
var v = Projectile.VelocityByTime(myRigid.transform.position, predictedPos.position, timeOfFlight);
|
||
|
myRigid.AddForce(v, ForceMode.VelocityChange);
|
||
|
}
|
||
|
}
|
||
|
}
|