Very very new to UE4, less new to C++, so I know this is a really stupid question but a few days of Googling hasn’t helped so I’m hoping someone here can help.
Wrote a script for an OpenDoor component class, which works fine when dealing with a simple standalone door mesh, but now I’m trying to apply that code to a blueprint whose parent is both the door and frame, and whose children are the doors. I’m not familiar enough with Blueprint yet to get into that, so I wondered if there was a way you can go from GetOwner() to something like GetChildBy Name(“NameOfChild”) so I can access the doors only instead of the whole collective mesh.
I apologise in advance for any stupidity/incorrect terminology.
If you want to access only the door mesh components in C++, you can keep pointers to those as class properties when setting up in the constructor. You can then access those properties easily anywhere you have an actor reference, or encapsulate door behavior in public actor class functions.
If you’re using a blueprint and have a class that extends the actor which contains your door components, just drag those door components into your blueprint event graph. You can then create events that can be called from other blueprints that can use those door components.
Thanks for this. I’m sure it’s spot on but I just don’t know how to d what you’re suggesting. I think that’s a sign that I stop trying for now
I think you have the question written wrong.
If you want to get a specific component in an actor instance, you can always use GetComponentBy… functions. You can get it by class if the door component has its own class, or you can get it by tag if you have many components of that class in the actor (i.e. you are using StaticMeshComponent).
But if we take the question literally and you want to get a child class from a parent actor instance, we are talking about class inheritance and the only way is to cast that parent class pointer to the child class.