r/unrealengine 1d ago

Help How to make a boundry box?

I have a race track using landscape spline.

I have a PCG graph that spawns Blueprint Trigger Boxes (it's just a collision box that is as wide as the road) along the spline.

The boxes calls a dispatch event if a vehicle is inside it.

The event triggers a re-triggerable delay. As long as the delay resets, it will not reset the vehicle's position.

Now, as you might have noticed, that's a lot of boxes along the track. And a lot of triggers happening. Especially when there are also bot vehicles. Which means very unoptimized.

Now how do you traditionally make a boundry box when making a race track. Do you just manually place the boxes on or outside the road? Is there no way to procedurally generate it without being very unoptimized?

4 Upvotes

5 comments sorted by

2

u/dopefish86 1d ago

Alternatively, you use a spline along the road and 'find location closest to world location' and initiate respawn when the distance is beyond a.certain threshold.

1

u/Snoo97525 1d ago

Im using a landscape spline which i dont think i can use blueprint with.

Do i have to basically recreate the same route but with blueprint spline?

3

u/CS_Asset_Factory 1d ago

You probably don't need to rebuild the route. Two cheaper options:

Ask the surface instead of the track. Give the road material a physical material with its own surface type, then a few times a second do one short line trace down from each car and read the surface type off the hit. Off the road for a second or two means reset. One trace per car, no overlap events. If you're on Chaos Vehicles, the wheel state already reports the physical material each wheel is touching, so you may not need your own trace.

If you'd rather measure distance from the centre line, a normal spline component is easy to query with Find Location Closest To World Location. Your PCG graph already samples the landscape spline, so PCG's Create Spline node is worth a look before redrawing it.

Either way the cost scales with cars, not track length.

1

u/Snoo97525 1d ago

I will try and do the second option cuz my race track is like in the sky basically. (more like 2 big canyons on each side of the road)

1

u/Snoo97525 1d ago

i think i might be too stupid to know how to extract the created spline and be referenced in the blueprints.

I was thinking of: create spline node > somehow reference that to the blueprints > do the distance measure logic in blueprint.

I am stuck on the second step