Download

Prevent Overlap with self

So I’ve got a frustrating situation… I’m working on a traffic simulation. I have an actor called BP_TrafficVehicle and I’m spawning the actor at world 0 and then positioning it along a spline at a random location by using the SetNewTime function on my timeline.

The problem with this is that I have no way of knowing if a vehicle is already occupying that space and it eventually causes vehicles to intersect with each other. I thought this would be an easy fix by adding a capsule collision to my vehicles and then OnBeginOverlap, delete the other actor. For some stupid reason though, it sees itself as the Other Actor and deletes itself instead of the incoming vehicle. This causes all sorts of blinking to happen where a vehicle was driving down the spline and then all of a sudden it’s replaced by a different vehicle in a similar, but not quite the same, place.

I don’t know how to tell the collision capsule to ignore self, other than running a branch of != Self but it still thinks the other actor is itself. I thought the whole idea of Other Actor was that it’s getting something that isn’t itself. This engine frustrates the **** out of me sometimes.

Have you tried a sphere trace by objects prior to spawning?

So the problem is, they’re all spawning at world 0 and then being moved along the spline, so I can’t trace prior to spawning or even at spawning because they won’t be colliding with anything. Once they are positioned along the spline is when the intersection is happening.

Do a trace on the spline position before moving.

Wouldn’t help. I need to figure out when they’re intersecting with another vehicle and that only happens when they’re placed along the spline. I suppose I could try to run a sphere trace instead of the overlap is I guess what you’re saying. I’ll try it and see if it works any better. It’s still weird that an overlap would happen on itself though.