Download

Possible to check if location is within a collision mesh?

I’m wondering if it’s possible to determine if a particular location resides within a collision mesh?

Any insight would be appreciated.

Trace?

What’s the purpose, might help to understand what you are trying to achieve

copy-pasted from UTPawn’s PlayFeignDeath() :


foreach CollidingActors(class'UTVehicle', V, GetCollisionRadius(),, true)
{
	if (IsOverlapping(V))
	{
		// moar stüfs
	}
}

seems expensive depending on the context though so I’ll join the question of what your purpose is with this

So for some context: In my game, players are able to build structures on my landscape map, and due to this i’ve written my own AI navigation system so AI can negotiate dynamically placed objects.

The system works by drawing traces down onto the landscape from above in the direction the AI wants to travel. Then does some more logic to figure out if the chosen path is blocked. It works great up until the AI tries to go underneath some rock structures (like a cave). Currently if the trace hits a static mesh rock, it deems the path invalid, however I’d like to trace down onto the landscape and then figure out if it’s overlapping any collision.

I think the above solution would be a little too expensive. I’ll have to think of another approach.

Maybe a traceactors after you hit a static mesh rock with the original trace. The traceactors traces all actors in the line, if it hits landscape wouldn’t that mean there’s a gap (i.e. in a cave) otherwise it’ll not collide with the landscape as the mesh is buried into the landscape?

Also did you experiment with turning on path colliding on the static meshes, think they are off by default and on for interp actors but sounds like you don’t do any nav pathing?

how high is this ‘above’ ?
you could start the trace at the pawn’s topmost point and still trace downwards. this way you’ll still be able to climb a bit your terrain but you’ll effectively avoid anything that the player can’t vertically fit into.
however just using the pawn’s topmost point would mean the pathfinding would fail on a continous slope if your calculations are somewhat long (i.e. your pawn’s topmost point will already be under the landscape some distance ahead). so for that you’d need to offset every next trace based on the previous trace’s hitlocation

here’s a quick sketch to show what I mean:
3595b10a95617e7133384ceac111d5408c5b92f4.jpeg
the white line under is the landscape and the one above is your cave. the blue box is the pawn, the yellow lines are the traces with orange hitlocations, and the green lines are just the vertical offsets.
you can see the first trace is made from the pawn’s topmost point, then you take the vertical offset between the hitlocation and the pawn’s lowermost point, and use that to shift the next trace.
eventually with all the traces ahead your dude would still fit into the cave

@Chosker that is a very interesting idea. I may incorporate some of those ideas into my system. I would have to reduce the distance of each hop from what it is now though.