Hello,
I am having a hard time understanding the “logic” behind the following syntaxes:
Debug.Log("I hit this thing: " + hit.transform.name);
The line hit.transform.name reads like the ray hits a transform which has a name. This looks like the transform has a name, although the name belongs to a game object.
And this:
EnemyHealth target = hit.transform.GetComponent();
This kind of looks like the ray hits a transform which has a an enemy health component. In other words a transform component which has a enemy health component. From what I know, a component belongs to a game object and a component does not have another component. The enemy health component belongs to the enemy game object.
What is this transform doing between hit and name, and between hit and get component?
Thank you for the clarification!