I am trying to access a method from another script, but I am getting the protection level error.
Even though I made the method Public.
This is the method I want to access:
public void Shoot()
{
timer = 0f;
gunAudio.Play ();
gunLight.enabled = true;
faceLight.enabled = true;
gunParticles.Stop ();
gunParticles.Play ();
gunLine.enabled = true;
gunLine.SetPosition (0, transform.position);
shootRay.origin = transform.position;
shootRay.direction = transform.forward;
}
And I am trying to access it from another script with this line of code:
if (hit.transform.name == "MyObjectName" )
GameObject.Find("Gun").GetComponent().Shoot();
How can I make this work ?
Thanks.
↧