[Request] Point Trace

I have been searching the forums and answerhub for a few days now and I don’t think what need exists in blueprint.

We have line trace, and it is great for a lot of things. But, maybe not the best for cases where you have a vector, know something is there, and just want to call the present actor’s functions without much hassle.

Basically get vector, is an actor there? If yes, then call its functions! :slight_smile:

With the line trace I have to line up the vectors, ensure nothing is in the way or exclude anything that could be in the way(a mountain tile for instance), do a small amount of math, etc. All small stuff by itself, but when my map generator needs to do it millions of times it adds up. A point vector could remove at least 8 nodes compared to the equivalent line trace.

Anyway, I hope you understand what I am trying to say. Thanks! :slight_smile:

You could do a distance test against all of certain types of actors or all actors :slight_smile:

you’d use a foreach loop and test AActor or some sublcass of AActors, and use Get Actor Locaiton, and test the distance to your chosen point.

If distance is small enough you’d count it as a hit



Hi Zeustiak,

Perhaps a SphereOverlapActors or SphereOverlapComponents query would do what you want? It returns all actors/components that intersect with a specified sphere (you can always make the radius very small to simulate a point check).

You can also define custom collision channels in the project settings, which may be useful if you are doing a lot of collision queries against specific groups of objects and don’t want to filter others out manually.

Michael Noland

If I call all actors of a class that could be thousands of actors since I only know a tile will be at the vector and nothing else. I think that would be rather cumbersome unless I misunderstand your meaning.

That seems pretty close to what I am looking for, though maybe still more than I need. In terms of performance, would a Sphere overlap be more or less efficient than a single line trace? Lets say the sphere is 1UU wide, where my line trace might have to be 16K UU’s long.

I feel like I have a conceptual problem regarding blueprint communication, though I think it is starting to clear up.

If I create instancedstaticmesh actors, and load them into an array as I spawn them, I can cast to any specific index of that array and call functions on only that specific actor?

I’m told by NVIDIA that doing a Sphere Overlap with a zero-radius sphere is how to test a ‘point’ in the world.

Heh, that makes sense thanks!

Yeah, if you spawned the actors previously then you can just keep a reference to them in an array or whatever and access them in constant time without having to do a trace at all.

For example, if you’re making a 2D grid game (match 3 or whatever), then you might spawn a 10x10 board as 100 actors or components in an array. Later on you can take some arbitrary mouse/touch position, scale and bias it to the location of your 10x10 grid and figure out what the X and Y coordinates in the grid should be (or if they’re outside of the bounds of the grid) and access that component directly.

Michael Noland

That sounds great!

Though, what is constant time? I did a quick google search and kind of have an idea, but not really sure what that means for my blueprint.

Hi Zeustiak,

Basically I meant that there is no dependence on the number of components in how long it would take to find a single component. Traces are not constant time, they depend on the number of objects in the scene, where the objects are placed, and where your trace starts and ends (PhysX builds an acceleration structure to help it do traces and queries faster than just checking every single object in the scene).

If you’re interested in reading more, here’s the start of a wiki walk:

Michael Noland

I see.

Since I can store all my actors in a precisely ordered array, it sounds like I should use those pre-determined indexes for all my tile related operations.

Then I can use the Sphere Overlap(referencing the Arrays) and other methods when I am trying to track down units that may be moving around the map.

Just an FYI, using 0 on the SphereOverlap radius doesn’t work, but .1 does. :slight_smile: