Question by 
               Ian2333 · Nov 19, 2018 at 09:01 AM · 
                scripting problemscript.scripting beginnerscriptingbasicsscriptingproblem  
              
 
              Set public gameobject by raycast hit target
I have a "public GameObject targetidentity".
Then I have a function:
void returntargetidentity() { RaycastHit target; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out target, range)) }
Thus how do I set the public gameobject to whatever gameobject hit by the raycast function?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by hameed-ullah-jan · Nov 19, 2018 at 09:12 AM
targetidentity = target.collider.gameObject;
Thanks for answering. But what does a collider have to do with raycast?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                