So basically, I have a project where I have a list of objects. You select that object and it opens a level where you can manipulate that object. I create two lists. One list contains all of the components of the object and the other list contains a custom functionality unique to that object.
Currently, I have this logic sitting in the level blueprint and it is tightly coupled with the Pawn. Mostly because it is waiting on references to be filled in at BeginPlay event. Currently, I have an event dispatcher on the pawn that makes a call once event tick happens the first time and then it disables the tick. This is basically for the timing of everything and ensuring the references are no longer null.
What I have essentially works as it is but, it isn’t really an elegant solution. I was wondering if there was a better way to kick off the event other than using the event tick. I am open to any suggestions you might have.
To recap, because of the way Unreal loads assets, the Level BP is loading before anything else and is trying to get a reference from the Pawn that hasn’t been set yet. The only solution I have found is putting it inside the event tick. Is there another way to do this? Screenshots below.
Level BP BeginPlay:
Pawn BeginPlay, the reference I am trying to get:
Pawn event tick to call event:
It may not be the answer you want to hear but the best solution would be to move the logic out of the level blueprint, it is not designed to be communicated directly with (event dispatchers are basically your only option). It would be easier to use game mode or game instance instead, or even a few other framework classes depending on your logic. In fact I almost never find a need to use the level blueprint.
If anything you could at least move the tick logic on the pawn to the event possessed. This event will fire after the pawn is created and controlled by a controller, that would then call your event dispatcher, no need to set “has enabled local pawn and disable the tick”.
I was able to move most of my logic out of the Level BP. My only problem and the reason I have to use the level BP is because I need a reference to certain meshes inside of the Level. I have multiple levels and I want to do very custom actions with different meshes. I know I can make a BP to handle the custom actions but, to encompass them all into one parent BP is the challenge which is why I just threw it inside of the level BP instead of creating like 10 unique BPs.
You could create a unique blueprint for every mesh if the logic was that unqiue for each, with a parent blueprint if they shared any logic, this way it could be references and used on any level. You could also put them all into a single blueprint if you wanted, what you could do is add a mesh as a component, then add a exposed name variable called “meshID” or “meshaction” or something, then you could start your logic with a switch on that name, (add all the name options to the switch), then do each peice of unique logic off of the switch. (You could also use gameplay tags, which would be another step up).
could also use streaming levels then use the level bp in the streaming level since you can reference it. its a trick i saw Zac Parrish use in a live stream once.
it looks like your just trying to call an event in the level bp once the player pawn is created right? if thats the case why not just use a interface? with a interface you could basically just call the interface event onbeging play of the pawn.