How can I move spawned actors towards a centre point?

It sounds like you have a certain problem ( which we don’t know ), and have decided this is the solution, whereas, it may not be a good way forward.

Are you trying to spawn actors at impact points without overlapping other actors perhaps?

The general case of finding the edge of a mesh is not straightforward.

If you are trying to spawn non-overlapping actors, it might be easier to have special versions of them with the pivot point at the edge of the mesh, the there’s no problem.

It really depends on what the actual problem is.

Ah, more information :slight_smile:

It was the other actors in the level I was thinking of.

Are all these spawned actors the same shape?

It’s also the problem of not being able to cope with the many different shapes of actors in the world ( and how to remain outside them ).

Hi,

I have a pawn that I draw some line traces around in a circle on the X axis. I then spawn an actor which has no collision at the end of each line trace using a combination of the ImpactPoints and TraceEnds. This means the spwaned actor clips into other objects.

How can I move all the spawned actors along the line trace’s normal so that the edge of the actor is at the Trace Ends or Impact Points? I have an image I hope shows the problem and desired result better than I can explain :slight_smile: many thanks.

The actors are all spawned at BeginPlay, then their location is changed every tick relative to the pawn in the middle, kind of like a force field. When there is an impact a force is sent along the normal to move the pawn in the opposite direction of the impact.

I have no concern for the spawned actors overlapping each other, only other objects in the level.

I’ll agree with ClockworkOcean here. There really might be a better solution but we do not know all the details.


For what you’ve described, this should work (fingers crossed):

Or use Trace End instead of Location if you do not care about obstacles in the way.

Alternatively, use a sphere trace and feed it required radius, you’ll still need a bit math - not sure if this is any good here; can the trace squeeze through a narrow opening? If you do not know the size upfront but know the class of the actor, you can get bounds from the class defaults (or a perhaps the actor knows its size and it’s a matter of getting a variable?).

There simply is not enough details to account for all possibilities. The above may be a solution but may not be the best solution.


If the actor has an irregular shape (ovoid, egg, banana, umbrella) and you cannot use set radius, you could Sweep. Sweeping stops short of destination. Again, Implementation would depend on the detail.

Sweep or Sphere trace then it is imho.

Then what @Everynone says below should do the trick.

Yup, they are all small spheres and there are no plans to change their shape :slight_smile:

The algorithm you gave worked exactly how I wanted, many thanks :slight_smile: but also thanks for highlighting Sphere Trace as it may actually be a better solution for my game :wink: