Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Reparenting the level blueprint

I'm currently looking for the best way to set up the following: when a level is loaded, a variety of actor parameters inside the level is set up based on an array of global flags stored in the game instance. The logic for getting the flags is shared for all the levels but what is to be done when these flags are set has to be customizable in each level and be as flexible as possible (e.g. some flags might toggle or replace NPC dialogue, some might switch the NPC behavior, some might replace the NPC with a "dead" model, the list goes on, and one flag can be used in multiple levels to add on top of it).

After exploring my options, it seems that the level blueprint is the best place to have this functionality: out of the box, it is loaded automatically when the level is loaded, it can access all the actors in the level without going through the hassle of setting them up, and it gives me the extent of flexibility I want in the system.

However, I ran into a problem trying to set up the shared part of the logic - getting the flags and so on. This would normally be easily solving by making a parent object and then extending for individual levels, but alas I can't seem to find a way to do this with level BP without doing it in C++ (I've seen the excellent Rama's guide but I have little experience with C++ and reluctant to take the dive without proper preparation). Now, I can of course just copy-paste this stuff from an empty level each time I make a new one, but it has an obvious fatal flaw of having to redo everything in case I decide to change something in the shared logic.

So, is there a way to reparent the level blueprint to have the extended functionality I want without involving C++ I am missing? Or is there a better way of approaching this problem in BPs? Or should I brace for impact and go down the C++ rabbit hole?

Product Version: UE 4.16
more ▼

asked Jul 05 '17 at 04:47 PM in Blueprint Scripting

avatar image

6 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

If all you are looking for is data management, then a Blueprint Struct might be something you are looking for. You would create it with all the data you'd want, then add it as a variable to the level blueprint and extract/set data as needed.

This isn't a very scalable solution if you are going to have many variables due to the visual limitations of Blueprints.

The C++ portion of this is fairly simple if you want to tackle it. You'll have to create a class that extends LevelScriptActor and set up your variables in there, then your Level Blueprints can parent it. This method is way more flexible and easier to manage than the Blueprint Struct. It is also more stable, as I've frequently ran into issues with very large structs.

more ▼

answered Jul 05 '17 at 05:02 PM

avatar image

161 9 10 20

avatar image Vallynne Jul 05 '17 at 05:19 PM

The problem is there's no fixed number of specific variables. One level might take flags A and C, the other B and D and E, and the third one C only. And for the specified flags it needs to get their values from the array stored in game instance/save game which basically contains all the global flags. It is this functionality that I want to be shared. Then each level blueprint would go on its way to do whatever the level designer wanted with each of these flags. I may be misunderstanding but I believe the struct won't be of much help in this case.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question