Linetrace check if Static Mesh is specific object?

This seems like the most basic thing but I cant seem to get it to work.

Im just doing a simple linetrace from player to object, and a true/false to determine if its a chair or not a chair. Unfortunately the equal to object node always returns false, I understand that its because the output is an actor comparing to an object, which will always fail. But I dont know how to get the object type of the static mesh actor to compare using the equal to node.

Right now, as you can see, its getting the instance name (sm_chair11) instead of just the object type (sm_chair) which is what I need to compare to.

Also I cant use the “cast to” solution as that doesnt work with static meshes, only actor BPs.

Huh maybe its fate but I just took this screen shot to ask my own question, weirdly enough it shows you exactly how to set up what your trying to do! The linetrace is returning EXACT references to specific actors, and you are just saying “check and see if any of these Specific Actor references are equal to the Generic Blueprint itself”, not any particular reference, which will never be true.

Compare the hit result to all known references of the actor your trying to get a hit result for using a “Get all actors of class” node and a “For each loop” node.

alt text

Many, many ways to ID something. Tags, Interface Queries, custom IDs. But perhaps all you need is to compare the class if you’re looking for chairs only:

Compare the hit result to all known
references of the actor your trying to
get a hit result for using a “Get all
actors of class” node and a “For each
loop” node.

I’d avoid this at any cost. Slowest, the most inefficient, ham-fisted brute force method :slight_smile: Last resort only. I’ve yet to run into a situation where this would be needed.

A tag system can be made neat:

Also works with components for that extra granularity but does require a bit of upfront setup. Like everything else that works.

Unfortunately none of these answers work as they all rely on the query to be an actor (BP) and not a static mesh.

Im specifically trying to get this to work with static meshes, SM dont have tags, they dont appear in get all actors of class and getclass only returns “staticmesh” not “sm_chair”

All of these work, I’ve been using them daily for years :slight_smile:

SM dont have tags

Any component can be given a tag. Here’s a static mesh with tag, for example:

If you wish to focus on Static Meshes only:

And yet another method of filtering is trace / objects channels - super efficient and works on groups:

Custom channel Ignored by default:

My “chair” is blocking it though:

Now I can trace on that channel:

Image from Gyazo

This way only static meshes whose collision responds to this type of trace will report back.

The above can be combined with tags, too.

1 Like

omg, u genius… Tell me pleas, can I make my only particle from the Niagara fountain recognize which specific static mesh it hit?omg, u genius… Tell me pleas, can I make my only particle from the Niagara fountain recognize which specific static mesh it hit?