Reference to a component for another component

Just to add a little explanation to this for beginners:
You create both variables (actor and component references). The component reference is not an particular instance, but after executing this you will have to find if that actor has that type of component or not.

If you want to do it just with “actor” and not asking for a component type, I suggest you call the same to get “comp” but instead of TypeOfComponent, you call YourComponentClass::StaticClass(). You can’t use “YourComponentClass” name directly on GetComponentByClass.