Hello fellow game developers.
I am just wondering if anyone can help me out.I have a script A which is on my main camera and it’s creating rays where ever i click.I was wonder how would i acces the location of that ray location which hits a plane mesh from a script B?
If multiple scripts need to use that value throughout the game, you can make the value static. So you’d have something like this:
public class CameraRay : MonoBehaviour {
public static Vector3 hitPosition;
void Update() {
//....stuff....
hitPosition = Hit.point;
}
}
Now every object in the scene has access to the location by: CameraRay.hitPosition
Hope this helps!
-Gameplay4all
So far i just have one script that would need to acces the location of that ray.What can i do if the value changes? Since the ray changes the location beacause it depends on where you click on the screen.
Thanks for the help 