hi, how to get component with raycast, with the component havin different names on each object?

object 1 → component name “conversationOne”
obejct 2 having component “conversationTwo”
etc,. i need my raycast to pick up a layer npc which it does , i just dont know how to get the components since its diff name on each object. thanks :slight_smile:
isn’t there like a index of componenents sorted by numbers , so i could put the component on say, fourth position and then getcomponent.4 :slight_smile: ? :slight_smile:

You can make them inherit a base component(class), and get it on your raycast then use reflection like GetType or typeof or is/as.,You can make them inherit a base component and get that from your raycast, you can check for the type afterwards using is or TypeOf or GetType.

You can use tags for this problem tag the required components with a specific name and
use GameObject.Reference is [here][1].There are multiple versions use according to your use case

@Reedex
[1]: Unity - Scripting API: GameObject.FindWithTag