I am making a moon game. I am wondering if someone can send me a tutorial on how to make something; for example an enemy or moon camp, appear when you get the mission. Basically at the start of the game, you cant see it until the mission. A more simple way might be regions being unaccesable until the mission, as if there is an invisible wall keeping you from going there.
With a spawn point actor, if the level gets unloaded, with a bool variable that reads the condition so if the level gets loaded and the condition hasnt been met, the actor doesnt get spawned, if it has then it gets spawned. If you need it to get spawned while the level is loaded, with an event dispatcher from a “dungeon master” actor that manages the progress with events (or a referee if you are into sports), like if in your game the player needs to grab 100 coins to open a door, when each coin is taken it send a message to this dungeon master that tells it “hey im a coin, i have been taken”, then the dungeon master keeps track of the coins and once the 100th coin has been grabed it shouts to every actor “THE DOOR IS UNLOCKED!!!” (or chapter ##, or whatever you think fits better to your progression of events), then the door actor hears that and behaves like unlocked, for my logic i do it as if it was a movie or stage play. I try to keep the logic in simple binary events for the most part.
Also, I would recommend to have a record of events in either the game instance or in game state (create your own BP), so every actor has access to variables that should be global without having to store references to actors it has no business talking to, like to avoid respawing of enemies the player already beat, on begin play it ask if such enemy was defeated or how much health it had when the actor was destroyed on unload of streaming level, just create a variable of type set for killed enemies. This, mixed with the dungeon is a behaviour like the Dungeon master writes the events for every actor who wasnt present and didnt hear the shout (the event dispatcher) and when they need to know if the should do something they just go to read the list on the board, either if the game has progressed a chapter and now a type of enemy shouldnt appear anymore, or if a different enemy/item should spawn.
This is helpful, really got what I wanted into a way others would understand, If you have a tutorial you could send where a dm would activate a door after something is finished\collected that be great!
Sorry, dont have a tutorial, but just begin small. I always use print string nodes when i want to achieve some behaviour and have no clear idea how to do it, just to follow the logic path. For example i want to know if a collision is happening, i put a print string node that says “I have been collided!!!”, the if i want to be sure a specific instance executed it and no other one, i a get self reference>getdisplayname>Append, and the print “[Actorname] has been collided” once i get predictable behaviour i replace with actual code.
Example
-Create your DM actor and place it on your world
–On your DM actor create the event dispatcher and an custom event. The custom event just make it print a string.
-Create an actor that behaves like a coin, (it gets destroyed on collision) on destroyed event, it comunicates with the DM and calls the event that will print a string.
–Once you get your DM to print something, change the print string to a call of the event dispatcher.
-Create another actor and place it on your world. On this new actor create a custom event and make it print a string. On this actor on begin play do a get all actors of class Dungeon master, since you will only have 1, get the index 0 of the array. (You could make it on construct and store it on a variable so the DM gets a stored reference when placed on the world, or manually assign a public variable) and do a bind event to the event dispatcher from the DM (remember, this goes in begin play.
–Repeat the test where the DM printed something, if it all worked out, when you collide with the coin, the DM will get called, and do the event distpatcher and you will get a new printed string but this time done by the actor that should only do something when he hears the instruction.
If you dont know how to use event dispatchers watch this video from Matthew Wadstein HTF do I? Event Dispatchers in Unreal Engine 4 - YouTube
Just make sure to assign the task to the correct actor, the one that will make the logic the simplest and cleanest, with the least IFs and the less references to other actors, for example if you want that in a certain part if the player dies you go to a cutscene where it was only a dream (Silent Hill reference), if you make the character handle it, you would need to have the death branching into a game over screen or a call cutscene, but if it just anounces to the dungeon master “hey i died” , the DM goes into looking what chapter is the game at, and chooses to either load the next level, or go to a gameover screen.
Again, begin with very simple logic, and build a building block at a time.
Ah. So there is a such thing as events that can be triggered. Example: If such and such is yes trigger so and so event?
yes, you can either trigger them with casting. interfaces or event dispatchers.
For for casting and interfaces you need to get a reference to the specific actor that has to do the event, which if is one of many or many at once is less efficient if you dont have the reference stored, because you would need to do a get all actors of class, and a for each loop, you might have 2-3 or 10000, thats why i use the concenpt of a dungeon master actor, so my many classes only talk to each other if they really need to (like in a damage event), otherwise just general manager. It that also allows you to not hardcode, maybe you need to activate a switch in level 9 to open a door in level 2, and both levels wont be loaded at the same time, and trigger many different events with a single action, unlock a door and turn on a light, or maybe late in development decided to change from a single boss to a horde, you dont need to touch the trigger event, just subscribe to the dungeon master and listen for an event (i use name variables so i only have to copy-paste text, or write the name of the big event)