Confused as to which blueprint I should be scripting on.

Which blueprint should I be using to place my game logic on, level, game mode, or actor?

For example, each of my ui maps I’ve been scripting on the level blueprint but have run into a problem where I needed my widget to bind to an event dispatcher called from the level blueprint. There doesn’t appear to be a way to get a level reference to the widget.

I understand that each level can have it’s own game mode, should I be coding on this instead? Or, do I make an actor class, code on that and drag it into the level (is that a standard thing to do)?

The specific problem I have is that I have a widget that displays a soccer fixture list. I have a button that when clicked will generate the results, I need the widget to update to display the results. The function that updates the scores is implemented on the level blueprint, I had planned to call an event dispatcher when this happens and bind the widget to it.

1 Like

You can get a reference to the level with

That might get you out of that particular hole.

Generally using the level BP a lot is not a great idea, simply because if you want to have any of that functionality anywhere else, you have to copy the code.

As to where you ‘should’ put it, well, how long is a piece of string? You will get a different answer from everyone here :slight_smile:

EDIT: Actually, having just tried it, I can’t find my level dispatcher, so… :rofl:

1 Like

I’m confused as whether I should mark this as a solution now haha

So I think I will do it in an actor blueprint. Is it a legit method to use actor blueprints for logic only and drop it in to the level even though it has no components?

1 Like

I do it :slight_smile:

Some people are allergic to actors that are hidden like that, but it doesn’t matter at all ( unless you have 1000s of them ).

Problem with dispatchers is you have to know the type of the thing you’re binding to.

( I would not mark it as solved :wink: )

Another way to do this, is to talk to the widget with an interface. When you spawn the widget you get a reference, and you can use a generic widget type variable to store it. Just send an interface call when you want it to update.

1 Like

Thanks. I will have to look in to interfaces some more. For now I’ll use a dispatcher and move my code from the level to an actor bp.

1 Like