Quantcast
Channel: Questions in topic: "protection"
Viewing all articles
Browse latest Browse all 107

Public void method is inaccessible due to its protection level

$
0
0
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.

Viewing all articles
Browse latest Browse all 107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>