I have an event that is called when I choose an option in a dialog with an NPC. From there I want to access an instance in the level, a door, and open it.
But I am not able to get a reference to this door. First I tried to create a Actor-variable, but for some reason “Editing this value is not allowed”. I can only edit this in the defaults of an actual, spawned instance of my Dialog. But I don’t want to place instances of my dialogs in the level, but instead in C++ I am working with the defaultObject.
Next I tried if I could iterate through all door-objects and filter out the one I need by it’s name, but GetAllActorsOfClass just crashes the editor for me. And I don’t think this would be the best approach anyways for an open world game. The number of actors of some classes could get pretty high.
Long story short: How can I get a reference of my door in the level to my Dialog-blueprint without placing an instance of the dialog?
As I said though, calling Get All Actors Of Class in my Dialog-Blueprint crashes the editor. Could this be caused by the fact that I call the event through the DefaultObject? If so, what other options are there?
In short, you need to Get Actors of All Class and then Cast to that door blueprint in order to send an input to that door in your level. Let me know if you cant find the nodes and i’ll post a screenshot.
Alright. It seems it is really caused by the DefaultObject. I will work around this by spawning an instance beforehand. However. Can someone explain to me why this happens? So apparently the DefaultObject isn’t a normal instance. But what is it then? Why doesn’t it work like other instances do? I would love to know why this happens, so I won’t run into similar problems again
starting the game results in a crash. It is caused by the GetPlayerCharacter. GetAllActorsOfClass also causes it. I assume everything refering to instances in the level somehow does. Just printing a normal string works though.
I assume I just don’t know something about the DefaultObject. It would be really helpful if someone could point out why this happens.