Accessed none trying to read property

Hey guys!

I’m having trouble on making my enemy follow the character. I’m trying to use AI Controller on it, but when I run the game I receive the error “accessed none trying to read property” when the game tries to read the Enemy AI information.

Can anyone help me?

Here is my code.


Which property is it getting an AccessedNone for?
I can see it maybe happening if the Get Player Character from index 0 is trying to get a Character when the player has possessed some other kind of pawn that is not a Character,
it could happen if the player at index 0 is not possessing anything at all (though that seems like likely than the first idea I had).

I am basing these comments on what I see in your blueprint screenshot above.

Hey Mightyenigma!

The message says it’s about the AI obtained in “Get all actors of class” node. My character is surely a pawn. How can i get it then?

I’m using the Twin Stick Shooter pattern and the character already comes as a pawn.

I tried now using “Get player pawn” but no success. The message sais the the ‘none’ is obtained when I use the “GET” in array.

Well, this may mean that there is no enemy AI, in the index you get or your pawn is not spawned yet.
When you use beginplay you should use “Is Valid” node, to check if object exist to pass the logic you refer,
also you may add a bit delay after beginplay, to give those objects time to spawn and load, so their reference will be valid, once logic refers to them.

Unfortunately, the EnemyAI exists. I’ve tried using delay and the “isValid” node where at false I print string and it’s printing. What could make it not a valid request?

Make sure you pick the correct class of “Enemy AI” in get all actors of class, also make sure that Enemy AI is placed on the level or spawned, before you use this logic.

It’s not placed in the map. It’s a AI Module type of class. Is it possible to place in the map? When I try to drag it in, nothing happens.

GetAllActors node can only get things that were placed in the map while editing the level OR were Spawned into the game world by a Spawn command during the game’s runtime, and are not yet destroyed.

What is the Enemy AI class based on? Is it based on Controller class, Pawn class, etc.? What does its Icon look like in your Contents browser it is a blueprint you created?

This is my EnemyAI class. I’ve created it manually.

Okay in that case, instead of GetAllACtors on the Enemy AI, maybe try GetAllActors on the Pawns they control, then GetController or GetAIController off of that, and cast to EnemyAI.

I haven’t made anything with AI in it yet so not sure if that’s the way to go but try it and let me know.

That’s what I’ve done. I’ve even put a print string at the end of the code and found out that the code achieves the last node, buit, for some reason, the object is no following my character.

I’m not receiving the error anymore, now I put my AI controller to posses the pawn and when the pawn is possessed it should start following the character. My pawn should have any movement controller like “projectile movement” for projectiles?

Thx for the help.

I’m not sure but if you want to use NavMesh functions like MoveTo, etc., I think I heard that they require CharacterMovement component so the Pawn should extend the Character class.

Again I have never tried doing this so it’s only a guess.

I’m trying with character too. I don’t know the reason yet but, using AI to control the movement is not working. When I use another node that doesn’t requires AI control, it works fine, but the character has no “Intelligence” and moves in straight line.

Hm did you ever Possess the pawn with your EnemyAI class?

Oops sorry you already mentioned earlier that you did. my mistake.

I’m sorry I can’t be more helpful. I think it would be a good idea to try some more tutorials on how to do this. I have found several good ones in the past.

Ive just found that it was because I had no “floor”. I’ve just put a floor in the scene and it started working. I can’t believe this.

Thanks for the help! :smiley:

1 Like

OH! yes that’s right - Navigation Mesh and its related functions are dependent on the floor layout, assuming that the character pawns controlled by the AI are going to be Walking :slight_smile:

I’m glad you found the problem and fixed it!

1 Like