Hi!
Currently I am trying to make a game with two goals and a ball where two teams try and score. My current problem is I have a game master set up to handle all of the things going on within the game but I can’t figure out how to set references to my two goal trigger boxes within the game master blueprint.
I tried setting them on beginplay but when the game starts up it gives me an Accessed None error.
What am I doing wrong here? Both trigger boxes are in the world so they exist. I am fairly certain I am just setting them wrong.
how are you setting your variables? is the blueprint that your showing one that is placed in the scene? what is this game master blueprint that your mentioning? is it one you made or is it something like the game mode bp?
the setup of this blueprint will determine how to get the references. for example if you place this bp in the scene then you could use a public variable to set the values. if this bp is a game mode then you could easily use the level bp to get the reference then set a values in the game mode. but it all depends on how you have things set up now.
So the way I currently have it set up is the game master is it’s own object that is inserted in to the world. The ball is spawned once the game starts, so I can’t use the level blueprint because it doesn’t exist in the world until the game starts (or is there a way to do set instances in the Level Blueprint when they don’t exist yet?).
Currently, I have a variable of each goal created inside of the Game Master and I set each of them to an instance of the goal from the drop down and then attempt to set them at being play with the blueprint shown above. When I do this though, the cast fails and I get a return none error.
The Game Master itself is just an empty actor that handles the score variables and interaction between objects.
If your goals are already in the level you can easily use the Level BP to create a reference to them. If the goals are spawned from another BP then that would be the easiest place to store them as a reference and pass that data along to the BPs that require it. You can’t set a variable the way you are doing it anyway. All you have done is create an empty place holder for the “type” of data you want to store (ie the goal BPs) but you haven’t actually provided a “reference” to the goals. You would need to use a “get all actors” node, the level BP, or some other method to get your “game master” to be given a reference to those actors. You could also use the level BP to spawn the game master and have it pass the references through to the game master on spawn this way you benefit from the level BPs convenience to create references but maintain the flexibility of doing all the work in a BP that is easier to access by other BPs (the game master in your case)
The “get all actors” node I believe is EXACTLY what I was looking for. I am not at my house yet so I’ll try it once I have access to my laptop but this has helped me a ton either way! The goals are already present but the ball is not and essentially I am trying to use the game master to process the logic of the ball overlapping the goal but I need to set a reference to both and didn’t really know how to do that within the Game Master BP. I’ll try this out when I’m home
So this is how I set it and it seems to work perfectly. Let me know if there’s something wrong with what I’m doing here.
Thanks again!
If you expose both red and blue goal variables in your game master blueprint (instance editable), you will be able to click on your game master instance in your map and see in the details panel that you can select an instance for each of those exposed variables, just click the dropper icon next to each property and then click on the red/blue goal in your world and this will setup those instances without having to find them yourself at runtime.