Why doesn't AddInputVector work for pawns spawned at runtime?

I created a very simple pawn class in C++ and set up a FloatingPawnMovement component in its constructor. I also created a Blueprint subclass of this class and added a component that displays content (I chose a Billboard component and set “Hidden in Game” to No).

In the Tick function, I call AddInputVector on the FloatingPawnMovement. If everything works correctly, the billboard (representing a bird’s head) should slowly rise.

When running the game, I have two instances of this class in the map. One was dragged into the editor, and the other was spawned using SpawnActor after BeginPlay.

However, you will notice that only one billboard rises, meaning the behavior of the object created in the editor is different from the one created at runtime. Why is that? Why can’t the pawn created at runtime properly call AddInputVector? The engine version is 4.27.

1 Like

The issue has finally been resolved. The main reason is that the pawn has an attribute called AutoPossessAI, and its default value is set to “Placed In World”. This means that only pawns placed in the map will be automatically controlled by the AI. If there is no AI controller, the FloatingPawnMovementComponent will not work properly.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.