Hi I’ve got a shooting script (below) attached to the camera. It fires a ball prefab but what I want it to do is when I hold the shooting button(left mouse button) down, it charges the shot so when I release the mouse button it fires the ball prefab with greater power.
Here’s the shooting script.
using UnityEngine;
using System.Collections;
public class Shooter : MonoBehaviour {
public Rigidbody bullet;
public float power = 1500f;
public float moveSpeed = 2f;
void Update (){
if(Input.GetButtonUp("Fire1")){
Rigidbody instance = Instantiate(bullet, transform.position, transform.rotation) as Rigidbody;
Vector3 fwd = transform.TransformDirection(Vector3.forward);
instance.AddForce(fwd * power);
}
}
}