- Home /
on raycast hit assign game object?
I've found that Raycst hit doesn't have a property of game object,
say if i had a public GameObject Target and i wan too use a recast from one object to hit a second target and then assign Target t the game object hit by a raycst are their any examples of this?
Answer by DavidWatts · Aug 26, 2016 at 04:42 PM
Raycast hit has a collider so you can use hit.collider.gameObject to access the game object hit if there is one. Probably best to check if the collider isnt null first.
Your answer
![](https://koobas.hobune.stream/wayback/20220612091602im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Physics.Raycast doesn't hit anything even though Debug.DrawRay works 1 Answer
How to make gun rapid fire 3 Answers
raycast not working after mesh deformed via shader 1 Answer
Raycast returns null for no apparent reason 0 Answers
Can't Instantiate the GameObject and make it parent to GameObject which it hits. 0 Answers