When pawn is possessed, spawn actor at given location, and when unpossessed, destroy the spawned actor. I want the location to be derived from the pawn’s origin * 2 on X and Y axes.
This kinda works, but there are a couple of issues.
First, the actor is spawned at incorrect and inconsistent locations. On some pawns in the level, the actor spawns closer, while on others it spawns farther away. It’s never at the actual desired location.
Lastly. while the actor spawns as it should when the pawn is possessed, for some reason it also spawns when the level is loaded. There’s no event that tells it to do so.
A small issue I’ve run into, is that the spawn happens a little bit higher than it should. With this setup, the actor should spawn at the same height as the origin of the pawn’s root component, correct? But it actually spawns 2cm higher.
It’s not a big deal, and I’ve used an Up vector node to correct it. I’m just curious why it happens.
After experimenting for a little bit, I figured out that I don’t really need the forward vector for anything. All I need is GetActorLocation + offset amount. But even without the forward vector node, the spawn still happens 2cm higher than it should.
Unrelated question: is it possible to spawn multiple actors with the SpawnActor node, or do I have to copy paste the whole setup?
Thanks for telling me about that! I’m working on an array with a bunch of different locations for the actor to spawn at. Seems to work, so I guess I’m doing it right?
As for GetActorLocation returning some wrong value, I don’t know. Maybe the issue is actually with the root component instead. I’ll look into it.
I’m more concerned with the other issue I mentioned in the OP. Why does the actor spawn when the level is loaded? It should only spawn when the pawn is possessed. I still haven’t found a solution to this.
Thanks for trying to help, but I managed to fix the issue.
As you can see in the blueprint, my pawn is supposed to spawn several actors when it’s possessed, but for some reason, the actors would already be spawned when the level was loaded.
I found that in the pawn’s class defaults, there’s a setting called Auto Possess AI, which (unsurprisingly) enables the AI to auto possess the pawn. So when loading the level, the pawn would be possessed automatically, which is why the actors were spawned.
This is probably obvious to anyone who is experienced with UE4, but as a beginner, I had no idea.