x

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"

Design, where to script levels if not in level blueprint?

Hello.

I am fairly new to Unreal engine blueprint, but em experienced c++ programmer.

So the question is: Where do you script level specific stuff?

There is a Button actor, and i want to call some actors OpenDoor function, or some other actors ToogleRoomLights function.

Lets say a room has door, window, lights, blending machine... Id go about this in Level blueprint with RoomEvent with Name parameter. Do a switch statement on the name, case 'OpenDoor' id make it call the door actors OpenDoor function, case 'ToogleLights' id call lights ToogleLights function... very simple easy, and fast.

And then the button, i can easily add the button to the level, when it's pressed have it run the level blueprints RoomEvent and pass the variable name to intro the RoomEvent so i can pass 'OpenDoor', 'ToogleLights', 'BlendFruit'.

But it looks like in Unreal engine you should make specialized button actor for each case? Have the button hold actor reference upon which to act, and have dozen different button actors for one room?

Not being able to reference Level blueprint, how do i go about this problem? just make dozen button actors for each case? or how do you do it in Unreal engine?

Product Version: UE 4.22
Tags:
more ▼

asked May 19 '19 at 10:15 PM in Blueprint Scripting

avatar image

BaneTrapper
7 1 5

avatar image IndieGameCove May 20 '19 at 07:44 AM

Not that I've even made a button before, but the way that I would go about it is like this. Make the button actor and add a public actor array variable. Bring it into the level and assign actors to the array. Then you make an interface blueprint Then whenever you trigger the button loop through the array and send out an interface message. call it action or something generic. So that way whatever you assign to the button does it's own thing with the same command. Doors open and close, lights turn on and off, ect.

If the door and light switches need to look different and play different animations you could parameterize that, but using child actors may be the way to go.

avatar image BaneTrapper May 20 '19 at 08:03 AM

What you mentioned i would have done, but multiple inheritance isn't a thing in Unreal engine. My doors and windows inherit from Destructible already. The light and electrical application inherit from ElectricalGrid. So i don't have that option.

My last resort is experimenting with Event dispatchers and callbacks, or using tags as suggested.

Trying to hack something in, i'l report progress.

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

1 answer: sort voted first

You can't access the contents of the level blueprint but you can still access all of the individual actors placed in the level. As a result you could use tags, an enum, a manual check for all actors of class within a radius, etc to find the actors in the level you want to manipulate.

more ▼

answered May 20 '19 at 05:43 AM

avatar image

SithHunter
95 8 10 12

avatar image BaneTrapper May 21 '19 at 02:18 PM

So i ended up using Actor tags. I tried searching are there limitations on actor tags, but i doubt i will be using more then 100 unique actor tags per level.

I made Actor WorldLevelName which holds logic for specific level. I script in this actor what happens when any specific tag gets called E.G:"RefineryToogleLight2" it pretty much accesses actor with specific tag, and toggles it's lights.

And button just has Name "RefineryToogleLight2" variable which to send to Actor WorldLevelName to act upon.

Flexible, dynamic, but also potentially buggy AF, but that's what am going with! Cheers on help!

avatar image SithHunter May 22 '19 at 01:15 AM

Glad to hear you got it up and running!

(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