Get clicked actor without line tracing?

I need to be able to click an actor, get its name so I can store it in a variable and compare its name with another.

I have tried line tracing without good results. I get some response, but not what I expect. As a digression, does the line trace node send a continous ray, or just one ray when it’s fired? I get back a whole lot of results, but I need one so I can store it.

This is what I have now:

Any suggestions on that?
Sorry if my attempt is ridiculous, I am new at this. Which is why I wanted to try such a simple game… :slight_smile:

Also, I’m wondering, is there no other way to get the actor’s name? Must I use line trace?

Thanks a lot

The line trace is a single ray that is calculated once when called. So every time you click you fire a single ray out.

If you absolutely had to you could implement a system that uses the player position + an offset based on the character camera XY offset, but that is really much harder.

Can you try printing the name of the class like so:

http://puu.sh/rdEux/d1f6485d93.png

There is a function called GetHitResultUnderCursorByChannel and might be what you need.

Thanks for your reply.

What makes me confused is; if there is only one ray, why do I get back so many returns? [EDIT: Also. it seems like the actor has a different name there…cards_BP_C…the name of the actor should be cards_BP_01_pair01] Here is a screenshot. This is from one click:

I tried the node you suggested. That was much simpler, but yielded the same result. Maybe there is some other setting that I don’t know about that makes this happen. This is the graph I have now:

Also, I wonder which blueprint would be appropriate for something like this. Level blueprint, playerController blueprint, the clickable actor’s blueprint?

Well, anyway, thanks a lot!

If I were to tell you to give me the objects hit by a bullet I shot you would follow the bullet and tell me the names of each person along the way. If I were to say that I wanted the name of all objects within 5 meters of me, you could also tell me that.

The trace returns all objects hit along the trace. Basically, a single ray penetrates several objects.

I would put this code inside the player controller. Why you get several hits, however, I do not know as it can be many things. Try changing the trace channel. Are the cards actually at different depths? Or are they all at the same location? Try moving them apart a little.

Regarding your original screenshot/setup, I’m not sure how the “convert mouse location to world space” node works, but are you sure you’re tracing in the right direction? (it looks like the line trace you’re doing is going straight down the X-axis in world space from whatever click location the node gives you).

Regarding your second screenshot with the cards and the butterfly, the reason it’s printing “cards_BP_C” a lot of times is because the TimeLine_0 “Update” output will tick every frame that the timeline is playing, and thus triggering the “Print” node.
It’s also printing “cards_BP_C” because you’re getting the blueprint class, and not the specific actors display-name from the level as your previous setup.

However there is something strange with your setup in both of these cases:
It seems like you’re using the logic in your screenshots inside of the clickable actors blueprint. If this is the case you could skip any line-tracing and just make a “get reference to self” node, and do the same thing you would have done with the actor result from a correct line-trace setup.

I didnt even see the timeline. :stuck_out_tongue: That explains everything. Thanks.