Hi, i need some help for this problem:
i’m making a simple 2D side scrolling game, i need to make the player pick up coins (like super mario, a simple overlap event).
I created a custom event in the level blueprint (which contains many of the game, score, highscore, coins, ecc), but i want it to get called by the blueprint of the coin (coins spawn randomly). I’m stuck on how could i call the custom event in the class blueprint. i tried to make a variable which contains the entire level but i get an error.
some screenshot:
this is my level blueprint
(i’m using console command as debug tool)
here’s the coin blueprint, in the red circle i need to put the custom event call
1 Like
You can use eventDispatcher for this
but to better orgonize your work , you can put your variables ( score, highscore, coins …) in your gameMode and cast it every time you need to change a value
1 Like
wow, thank you for both advices. I think i will move the code from levelBP to gameModeBP.
Btw, do you know any tutorial or example to suggest on the usage of event dispatcher? i never used them and i found the official documentation incomplete…
in your situation it can be a little tricky cause the coins are spawned randomly .
In general :
in your coinBP , you create an event dispatcher and call it
in your scene you select your coins and go to LBP, right click and tape the event
You Can look into my Tic Tac Toe game sample , i used it to update score
thanks a lot!
so, i firstly tried to move the code to game mode BP instead o level BP, it’s actually more clear.
this is the function i made in the game mode BP
while this is what stay in the coin BP
where swarm swarmGameMode is a variable that should contain the game mode BP
with this code the event in the game mode BP is nevel called.
so i tried with the event dispatcher:
first i created an event dispatcher in coin BP and called it
sorry for the lame question
but then, in the game mode BP, i didn’t understand how to make that event to actually make something
maybe your swarmGameMode instance is empty
you can try this
or this
Nice now works fine!!
Thank you!