so i’m coming from unity and something that was pretty easy to do was setup part of a script so I could set an object in the scene to be something the script does things with
for example, I might want a script to handle some lights so I would just set it up to handle an array of gameobjects and chuck the lights I want the script to handle into that array and let it do its thing
or I might want the script to move a block when another block is touched but that’s the sort of script I might want to re-use a bunch and with many different kinds of objects
currently in UE5 i have a blueprint that just handles some stats for me and other things go to it and just increment w/e those stats, currently to make that work I have setup a thing that just goes through the scene at the start and finds the statshandler actor so the rest of the script understands what it needs to use (if i don’t when i press compile it of course complains that it has no idea what BP_statshandler is)
is there a way I can set it up so I just link it together in editor?
is there potentially a better way I could be doing or even wording this (i have tried searching google for an answer but it appears I don’t know the correct words to get anything useful)
Not really know anything about unity, but “this ain’t how things work around these parts”.
If you want a certain instance obtain a reference to something else you can do that in LevelBlueprint. Level Blueprint has references to everything that you place within the level, so if you have 2 instances of 2 blueprints that can be placed into the scene, you can just drag them from World Outliner into LevelBlueprint and it will create reference for you, then you can call their methods and pass references to each other as well.
About the reusability of functions. UE4 AFAIK has no concepts of scripts as you know it from unity or what I slightly remember in godot. So the best approach to do it only once is by inheritance.
Each use case is different tbh.
In your case, using a StatsHandler actor can be an option. Place actor in the level, then whichever other actors need to use it, can use “Get All Actors Of Class” node to access it.
A better option (imo) here would be to put that stuff in GameMode, GameState, or maybe even GameInstance if you want it to persist through levels. Actors BP can also easily access those via “GetGameMode”, “GetGameState”, or “GetGameInstance”, then cast to your own subclass.
so, I should be able to set up something in the level blueprint that is or at least represents Actor A so actor B can be told to use that before compile? (instead of asking it to find the actor at runtime)
ah it would seem from that that saving these stats in gamestate is probably the best course of action as I might be using multiple levels
edit: or player state? (I’m not making a multiplayer game I’m just making a VR test environment for data gathering)