Hi, say you have an actor with a component. Can you get that component in a different blueprint without referencing its parent actor?
Yes
- If actor is unique, you can simply assign a tag to it and use GetActorsOfAClassWithTag->GetComponentClass->Check if its valid
- If its not unique then you have to search for something that is unique on it, a component or interface then same GetComponentClass->Check if its valid
- If you are looking just get this component without actor reference at all its not possible cause actor components lifecycle is part of actor.
- You can create a subsystem that holds some components and you can access those at max, however subsystem will anyway reference actors somehow.
What are you trying to do exactly? Why you are not referencing actor or you need not to?
Thanks. I have the component on multiple actors. I’m trying to access every instance of that component to retrieve some value from it.
I wanted to avoid Get All Actors Of Class, but I guess that’s not possible, right?
So thats where the system design comes in.
If your actors with that component is specifically doing something, that component can register itself somewhere.
EX:
ItemActor->OnBeginPlay->GetPlayerCharacter->AddToArrayUnique OfRegisteredComponents
ItemActor->OnBeginDestroy->>RemoveFromArrayUnique OfRegisteredComponents
That way you don’t have to search actors of a class everytime, you can just ask the array which holds components. So its more efficient also more contained.
A subsystem would be suitable for that. It’s not hard I suggest code some C+ if you don’t since you will need anyway if you are a solo dev.
Do you think so? I thought I could avoid C++, mostly because it brings more bloat than it’s worth. I’d have to use Visual Studio too, or some other IDE.
My game is small in scope.
you can avoid if you want to, better not to since traditional programming in pretty much every language has its benefits, some things would be much more easier.
Even though its small scope (which is good) start from somewhere and the rest is history. Languages, environments, engines, development environments, studios can change but knowledge is inherited.
You can make things with blueprints only for sure however, if you are solo do code the right way.
Understanding inner mechanics of how things works is literally a super hero power especially in game dev industry.