I cannot access to another class function by using LineTracing

You need to cast. Looks like you figured it out but you wanted to know more about casting so I will put it here so maybe it can help others.

Casting is basically saying “I am looking for this class and expect to find the properties of this class.”

For example lets say you have a base class “Enemy” that is a child class of “Actor” and then “Goblin” and “Minotaur” which are both child classes of “Enemy”.

You wont be modifying the “Actor” class as it is a base unreal class, but you modify “Enemy” class to have the variable “Health”.

This means both “Enemy”, “Goblin” and “Minotaur” will have a variable “Health” because they are parent and children, but “Actor” will not have it because it is the parent of “Enemy” where “Health” is created. We can now define “Goblin” “Health” at a value of 16 and “Minotaur” at a value of 40.

So if you are trying to get the “Health” of any enemy you need to cast to “Enemy” because it has the variable “Health”. Now it will not matter if it is a “Goblin” or “Minotaur” it will still be able to find the variable “Health” but if we try casting from any class other than “Enemy”, “Goblin” or “Minotaur” it would fail to cast and we could not find any variable in it named “Health”. You would find that a “Goblin” would return 16 “Health” and a “Minotaur” would return 40.

Now let’s say our character does bonus damage versus enemies of the class “Minotaur”. We can cast an “Actor” as “Minotaur” and if it is of that class the cast will succeed and if it was a “Goblin” it would fail, even though “Minotaur” and “Goblin” are both children of “Enemy” and grandchildren of “Actor”.

I hope this makes sense. Let me know if you have any more questions and be sure to mark this as answered once you have a satisfactory answer.