Files
DougDiggem/Assets/Scripts/Tools/Ballgun.cs
T

28 lines
697 B
C#

using UnityEngine;
public class Ballgun : Tool
{
[Header("Ball Gun Parameters")]
public float shootForce = 10;
public GameObject ball;
public float ballLifeTime = 5;
public override void Use()
{
GameObject newBall = Instantiate(ball);
newBall.transform.position = transform.position;
Vector3 direction = transform.forward * shootForce;
direction += GameManager.Instance.GetPlayerController().GetVelocity();
newBall.GetComponent<Rigidbody>().AddForce(direction, ForceMode.Impulse);
Destroy(newBall, ballLifeTime);
}
public override void UseAlt()
{
throw new System.NotImplementedException();
}
}