Spawn Actor Outside Screen

G’day!

Heads-up, I am not a programmer, so this might seem fairly basic.

I’ve been fiddling with UE4 for a while, and I am in a situation where I need to spawn an actor (or teleport, depending on the situation) to a random location. The crux here is that I need a location value placed behind the camera, out of view. Seeing as this is a third-person camera unrelated to the actor’s rotation, it’s a bit more complex than I had assumed.

My attempt was using a WhileLoop. I’d spawn the actor to a random point close to the player, convert that point to screen location and use that bool to dictate the loop. The loop would then spawn the actor to a new location, prompting it to check and see if the new location is adequate. Ideally, this would continue until the actor finds a spot behind the player. But no. That’s an infinite loop.

Pardon my lack of screenshots, but is there a good way of doing this? I’m quite lost here. Thank you.

The main thing you are looking for is Spawn actor and then attaching the actor to a component.

Here is a quick explanation http://youtu.be/Q-yvtjaL49M?hd=1

no unfortunate thats not what hes asking for at all. I am also looking for a way to get a point out of the view to spawn actors. EQS could handle this, but thats too heavy of a system to put in for my use case. the other was dot products of the spawn point to the player, then multiply by negitive the players forward. But that still had the chance of spawn to the sides.

OP, did you ever find a solution to this?

Get the camera of the current view target. It’s an actor component. You can get its orientation.
Offset backwards along the camera axis, perhaps clamped/normalized to the xy plane, and then project down to supporting/colliding geometry to find a good spot on the ground.

1 Like