Download

Accessing/Updating blueprint from AIController

Hi, I’m completely new to Unreal Engine and have a limited background in OOP so need some help. I’m following a book (Blueprints Visual Scripting for Unreal Engine - great book!) and building a simple game. I have an ‘enemy’ actor who when senses the player moves towards the player. When the player is detected, I wanted to also hide the enemy actor for a few seconds and then make it reappear. I was trying to do this from the AI Controller blueprint as part of the ‘On Seen Pawn’ execution path. I have created a variable as an object reference to the player in the AI controller blueprint but when I try this the reference always seems to invalid.

Hello,
could you clarify a bit for me and I might be able to help. When you say it always returns invalid are you refering to the check you do in the provided screenshot? If that is the case it should be noted that the valid check does not correspond to the sensed pawn. Currently you store the sensed player character as a blackboard key with keyName **PlayerActor **and you are checking if the value of Enemy is valid.

If Enemy is a variable retreived from somewhere else this might not be an issue depending on where and when it is declared and has its values changed.

Hi. Enemy is a variable I used of type Object Reference which she be pointing at the EnemyCharacter reference. However, reading another post it seems that it needs to point to a specific instance of the EnemyCharacter, otherwise it defaults to none. I placed the EnemyCharacter in the level via editor, it’s not spawned. I played around a bit and found that it worked if I used a GetControlledPawn function (target self), not sure why that worked but a get Enemy didn’t. Thanks.