Hello,
I want to be able to SphereCast and depending on which object the SphereCast hits then a different function will run specific towards that gameobject.
At the moment I have a script that has this:
if (Physics.SphereCast(origin, radius, direction, hit){
GazeTarget target =gazeRayHit.collider.gameObject.GetComponent<GazeTarget>();
if (target != null)
target.OnHit();
}
So when the Cast hits the gameObject that has the GazeTarget script then it runs the OnHit command from the GazeTarget script which works fine. I want to be able to run a different script/function depending on which gameobject I am looking at though and this currently has me stumped. For example I want to look at a car and display information about that car then if i look at a truck then information will pop up about the truck⦠etc.
Any help would be greatly appreciated!