Calling child function from parent

Hi, I’m trying to create endless runner game following UE4 tutorial on Youtube with a lot of differences. I would like to get Transfrom from child class into parent class. I would like to have this child function in every child so I can return the transform from any child (just with different values from different objects but the return type would be still Transform) at any time just by calling the function in parent.

If it doesn’t make any sense to you, just ask (even I don’t know how to properly explain this stuff)

I suppose I am missing something, but if you for example “get actor transform”, then you get the actors transform wether it’s in the child or parent. So calling that in the parent would be fine.
But in the case where a child might have a scene component which you want to get the transform from there are two alternatives.

The first method is to have that inside the parent. Say you have a parent tree class and all the child classes will be the different types of trees and you want to modify their transform in the parent.
In that case you can add a mesh component in the parent and then in each child set the mesh to the appropriate tree. So now you can just access the mesh component inside the parent class.

The other alternative is to have a function in the parent that returns the transform and just override it in the children. So “Get tree transform” inside parent, then each child will return the transform of their tree.

Thing is, in cases where the parent is not aware of X, but you want the child to give X to the parent so that it can do things with X… I’m not sure if that’s an acceptable programming design or if it should be avoided. Don’t get me wrong, I do this in a few places so hopefully someone with insight can comment.

Yeah, it would be for something like “tree’s transform”. I’m going to try the alternative method (since it looks easier), if it doesn’t work then I guess I will go with the first one. Also if anyone knows a better solution to my problem, its greatly appreciated.

Also I would like to know if my parents function should look like this?

and then I would set the Parent Attach Transform from the child ?

Yes, that’s what the function would look like, and you would then have to override it in each child class, passing in whatever data it is you want to give to the parent. You can also mark it as pure if you wish.

“and then I would set the Parent Attach Transform from the child ?”
I don’t know, you have a transform to work with now.