I’m making a 3d side-scroller game and I want to do a line trace from the character glasses to wherever I click on the screen with the mouse.
I want this trace to stay on the same plane as my character, so the X value of the start point & end point should be the same.
This is the best I could do, but it’s not accurate - When I click roughly in the center of the screen the trace is pretty accurate, but when I click further away from the center it gets less and less accurate…So…What am I doing wrong ?
You’re tracing with a fixed distance of 500, replacing the projection’s X with a fixed value. It’s actually hard to imagine how that would look like, a strangely distorted / twisted undulating surface mayhaps? , for sure.
I want this trace to stay on the same plane as my character, so the X value of the start point & end point should be the same.
create a virtual plane where the character is and point it towards X (Plane Normal 1,0,0)
project 2d mouse location into the world from the camera, hitting that plane (Intersection)
trace from the character’s head towards that Intersection point
That’s what I got from the description and intent. Do tell if it’s getting close.
maybe use get hit result under cursor…
Wouldn’t work if there was nothing under the cursor. And you’d need to play with channels to filter stuff out. Could work well in some scenarios, though - depends on how the world is constructed and how we’re interacting with it, ofc.
Just wanted to say thanks for this insight! Been trying to solve the problem of 2D mouse aim in a sidescroller for a few hours and this solution was exactly what I was looking for. Plus I learned about the Line Plane Intersection node, which I had never heard of before!