C++: Spawning ACharacter

Hi guys,

don’t know if this is a bug or my mistake so I guess I’ll post it here before going to the AnswerHub.

The thing is: I’ve been trying to spawn a Blueprint extended from ACharacter through the GameWorld()->SpawnActor<ACharacter> function (the syntax might not be correct as I don’t have the code here with me).

The character is spawned at the location and rotation I tell it to but the problem is that if I try to get the Controller of the newly spawned character it returns NULL (both in a BluePrint or in C++).

The same BluePrint, placed in the scene through the editor doesn’t have any problem.

Am I missing something?

Thanks!
Eclipsed.

You may need to possess the character you have just spawned. You will need something:


Controller->Possess(CharacterYouSpawned);

The character derives from the pawn class I believe so it should be fine to pass it through this function.

Uhm… I don’t think it will work, mainly because I don’t want to possess the character, it’s going to act like a RTS unit.
I’ll give it a try though.

Thanks!

Try

Spawn Default Controller

Untitled.png

That sounds like a solution!

I’ll try and I’ll let you know, Thanks!