Download

Cause Another Actor to Do Custom Event on Button Press

I take it the method I have below is just not possible for I can’t figure out what to put for object. If so, what would an alternative method be to accomplish my desires. I am using the top down template. I want it when I, the topdowncharacter, press the G key, the AI runs its custom event and currently prints “Hello” (later may destroy itself or play an animation or any other command I choose)

I created a Character class named AI1 and gave it a custom event in the blueprint.

Does anyone else have any ideas because I can’t seem to figure out a different method.

So you need a reference to the actor you want to talk to. Right now it is like you wanting to tell your friend Paul he needs to go to work but you just stand outside your apartment shouting into the void. You can get a reference in many different ways. I will give you some examples. Getting references was tricky for me to understand in the beginning but it is probably one of the most important things to understand in Blueprint.

  1. If you are in visual line of sight of Paul you do a line trace, when it hits him you tell him to trigger “GoToWork”.
  2. You are in close proximity to Paul, then you do an overlap event and then when you are sure that this is Paul you tell him to go to work.
  3. There is only one Paul in the world then you can to get all actors of class, get the first Paul in the array and trigger him.
  4. If the game mode is the one spawning Paul you can store a reference to Paul after the spawn and then you ask the GM if it knows Paul and copy the address and telephone number.

A tip is to always have a strategy for storing references. If you spawn something in the level that you need to keep track of like an enemy, store a reference to it. If the actor is already in the level from the start you can use one of the above solutions or hard code the reference by making it editable and expose on spawn. If you want to talk to Paul you could send a letter to every Paul in the world(pretty expensive) or get his email-address instead. Just shouting from a hilltop won’t do anything :wink:

Thank you, I managed to get option 3 working. You have a good way of explaining things without fully giving away the answer, thank you