Hello. I’m trying to make a script that only lets you create one shotSaw, then holds in in place while applying rotational force. However, it seems that the variable “charging” is not being set properly, and it spawns too many objects. Anyone know why it isn’t being set if (charging != true)? I just have the other functions disabled in the code for now.
function FixedUpdate ()
{
if (Input.GetButton ("Fire1"))
{
if (charging != true)
{
var shotSaw = Instantiate (saw, transform.position, shootPosition.rotation);
var charging = true;
}
//shotSaw.rigidbody2D.AddTorque (10);
//shotSaw.transform.position = Vector3(shootPosition.position.x,shootPosition.position.y,shootPosition.position.z);
Debug.Log (charging);