Is there something special I have to do when I spawn a pawn versus an actor?

I recently decided I had to change the class of my NPCs and creatures in my project into pawns versus actors so that I can give them AI.

But now I’m running into an issue with spawning them.

I have an actor in the level (well, pawn now) that spawns them at run time. At least it’s supposed to.

This was working just fine when they were actors. But now I get these errors:

Blueprint Runtime Error: "Attempted to access BP_TestCharacter2_C_0 via property K2Node_DynamicCast_AsBP_Creature, but BP_TestCharacter2_C_0 is not valid (pending kill or garbage)". Node: Set CreatureHitPointsCurrent Graph: EventGraph Function: Execute Ubergraph BP Level Manager Blueprint: BP_LevelManager

Blueprint Runtime Error: "Attempted to assign to None". Node: Set CreatureHitPointsCurrent Graph: EventGraph Function: Execute Ubergraph BP Level Manager Blueprint: BP_LevelManager

So, is there something else that the pawns need to spawn? Otherwise, is it possible to give them AI and have them be actors somehow?

1 Like

The first error means that you’re attempting to access an actor that has already been deleted, but is still in the garbage queue.

The second means the actor is not valid. You could get that if something is the garbage for long enough. Or, it never was a valid actor ( the reference was not assigned ).

Yeah, I understand that. What I don’t understand is why it’s not valid. I’m literally spawning it immediately before I try to set this variable; what is causing it to get deleted right away?

1 Like

I can’t see the call, can you show that?

In the screenshot above. Spawn actor, third to last node in the sequence.

1 Like

Ok, assumed it was elsewhere also… :slight_smile:

Are the characters appearing?

Have you tried changing the spawn collision to ‘always spawn’?

1 Like

No the characters don’t appear.

Always spawn fixed it. Just weird that they spawned in fine as actors with the same settings but not as pawns.

Thanks for your help!

1 Like