Hello everyone !
I am encountering a problem.I can’t get a value of a vector from a widged blueprint to my gamemode blueprint to set another value.I am doing this to setup a team system : if you click on a certain team , the vector will take a value and transmit it to the gamemode blueprint to change the spawn location.The big problem is i don’t know what target to put on my vector…Here are some screenshots of my setup
it might be easiest to do this from the widget blueprint. so in your widget blueprint, on clicked, you have your vector spawn location 1, then call ‘get game mode’, cast to GameMode1, then drag the pin out from game mode 1, and set vector ‘spawn location’ (the one in your game mode) . for the input pin on that variable, use the ‘spawn location 1’ from your widget.
Here’s a link to blueprint communication tutorials if you want to research this further.
ok, i think i see what’s happening, but let me know if i’m wrong. so game mode will actually be a fresh game mode every time you open a new level using that game mode. so every time you open a new map, you will need to initialize that variable spawn location. however, if you use a custom ‘game instance’, this will persist between level loading. so for example, create a new class of base class GameInstance, and in your project settings, specify your game instance class to be the custom class you just created. then in that class, store your variable spawn location using the procedure mentioned above. except instead of ‘get game mode’ and ‘cast to gamemode1’, you will use ‘get game instance’ and cast to ‘customGameInstance’ or whatever you want to call it. let me know if that makes sense.
Thanks for the help mate ! So i tried what you told me to do but it’s still using the default value from the vector .However i wasn’t sure where to link my cast to gamemode1 (this one)
Ok my friend so my first question is to what event do i link the blueprints in my game instance ?Also I shouldn’t delete the blueprint in the mainmenu right?
your basically passing a variable from one map to another map which requires the use of either a save game data or a game instance. so first, create a new blueprint myGameInstance. the base class for this blueprint is GameInstance. then, in myGameInstance, create variable GameInstanceSpawnLocation. In your project settings, maps and modes, set game instance to ‘myGameInstance’. In your widget onClicked, call get game instance, cast to myGameInstance, and set GameInstanceSpawnLocation to your desired vector. In your game mode, on beginplay, call get game instance, cast to myGameInstance, and set your GameMode spawn location vector equal to your myGameInstance GameInstanceSpawnLocation variable. sounds confusing, but will make more sense when you take it step by step.
OK makes perfect sense now that i read it over again and now it’s working. Thanks a lot mate you can’t imagine how much you’re helping me out! Keep it up !!