So i have this code as my original code:
var projectile:Rigidbody;
var TorpedoSpeed:float = 0.0;
private var launchLocation:Vector3;
launchLocation = Vector3(transform.position.x,transform.position.y,transform.position.z);
function Update()
{
if (Input.GetButtonDown("Fire1"))
{
GetLaunchLocation();
var instantiatedProjectile:Rigidbody = Instantiate(projectile,launchLocation,transform.rotation);
instantiatedProjectile.transform.Rotate(Vector3(180,0,0));
instantiatedProjectile.velocity = transform.forward * TorpedoSpeed;
Physics.IgnoreCollision(instantiatedProjectile.collider,transform.root.collider);
}
}
function GetLaunchLocation()
{
launchLocation = Vector3(transform.position.x,transform.position.y,transform.position.z);
}
but i want to re-code it so that this is the Input/Trigger
GUI.Button (Rect (1200, 800, 24, 24), GUIContent (PulseIcon));
So i did this:
function Update()
{
if (GUI.Button (Rect (1200, 800, 24, 24), GUIContent (PulseIcon)))
GetLaunchLocation();
var instantiatedProjectile:Rigidbody = Instantiate(projectile,launchLocation,transform.rotation);
instantiatedProjectile.transform.Rotate(Vector3(180,0,0));
instantiatedProjectile.velocity = transform.forward * TorpedoSpeed;
Physics.IgnoreCollision(instantiatedProjectile.collider,transform.root.collider);
}
}
but it is lagging my game to death and just overall not working, could anyone assist me?