I am currently working on creating a very simple game mechanic that uses drag-and-drop mouse controls. A player views a scene through a stationary camera (there is no player character on screen) and picks up objects with the mouse and drops them in the appropriate bin.
I have not been able to get the controls to work for the life of me, as I am new to Unreal blueprints. I’ve been debugging using print string to find where the issue is and, so far, I’m able to get the mouse coordinates properly, but once the data is fed into a line trace, it won’t recognize the actors I point to; all I get is red dots.
I would suggest you set the debug draw time very long, then use the editor camera (F8) while playing and move to the side to see what the line trace is doing: what it hits, how long the trace is, etc.
If you trace from the camera, you can’t tell how long the trace is and how close the hit occurs.
Also, you can print out the actor name you hit, which can tell you if you have something else blocking the trace.
Thank you. This was an excellent suggestion because it allowed me to see that the line trace wasn’t deep enough to hit anything. When I changed it, though, the line trace turned green after it passed through an actor, but it still did not print the name of the actor it hit.
Where did you have the print string connected? That can definitely matter. Try using an “IsValid” check after the line trace (the gray macro node, not the green pure function node), passing in HitActor. Then if it ISvalid, printstring with the name.
I suggest not running anything else on the execution line after the line trace until we confirm this- more code means more chances of error! If we can confirm this is working, then we know your issue is not the trace, it’s further into the code- and if you’re getting red square dot, you’re getting hits!
Thank you, this helped me figure out that I had the hit actor output connected incorrectly. The line trace is now showing the hit actors but my overall function of having the object highlighted under the mouse cursor is yet to work. I’ll keep at it!