Does someone know how to execute a function from another script. Following situation I have a Player Pawn and Enemy Pawns that get spawned every time you collected 50 points. There are some special collectables that make the enemy flee for a few seconds before getting back in Hunt mode. I wanted to call that Run Away function from the collectable script but non of the enemys do it. I tried it with normal Functions that I created, Custom Events and lastly Event Dispatches but non call these run away function. when I call the function inside the enemy pawn it will be executed from outside unfortunately not. Does someone know what my mistake is?
Enemy Pawn (When I simulate the “Bind Event to NERun Mode” will be executed (this func will be called from BeginPlay) but the NERundMode_Event not):
Collectable (When I simulate the Call NERun Mode will be executed):
Every Event Dispatcher Receiver have to obtain a reference to the sender object. (In your binding Events you have to reference the sender)
Btw: You dont need to loop through all actors and call your Dispatcher. Dispatchers are listening relationships.
Call Dispatcher > everyone who is listening executes the bind event.
For setting the “movement/run mode” Dispatchers are fine. But you have to rethink your food eaten function. Imagine you have two collectables at the same time, you eat once and according to your dispatcher both collectables are fired. An interface would be much more easier because you can reference the receiver.
According to your name i guess you are german. Kannst mir auch gern auf deutsch schreiben
Thank you very much for the tip with the interface. I got it to work with a complete new blueprint I think the problem is that I copied the foodie from another foodie class that makes the player faster for a short time. For any reason Unreal coudnt handle it that I copied it and didnt execute my functions properly. For a test I connected the Run function to the get fast function in the original foodie blueprint and suddenly the player got faster and the enemys run from me. But thank you very much for your time
Grüße gehen raus