28 lines
692 B
C#
28 lines
692 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.PlayerController.GetVelocity();
|
|
|
|
newBall.GetComponent<Rigidbody>().AddForce(direction, ForceMode.Impulse);
|
|
|
|
Destroy(newBall, ballLifeTime);
|
|
}
|
|
|
|
public override void UseAlt()
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
}
|