Hi Guys, I am using Unreal Engine 5.2 version currently and I encounter a problem which the line trace is not following along my crosshair The blueprint I used is simple line trace blueprint that usually how people working on but it is weird that it doesn’t work on my side. Anyone know what is happening?
- how does it manifest? What is the result you’re getting? What is the expected result?
- what’s the value of
Trace Distance
?
It is hard to guess what is happening and why this doesn’t work. You can check one of the following:
- Cine Camera is not properly assigned
- Trace Distance is not enough
- Collision responces are not set properly
Also you can try using Get Screen Location to World Space so you are sure the direction/location of the ray is correct - you just have to feed it the mouse pointer coordinates, which is a bit tricky sometimes
Hi, The result I expected is the result that the line trace is following with my crosshair which is the center of my scene but the line trace now is inverted with my input as you can see the screenshot below; when I move the view to left the line will trace to the right
I used Cine Camera for my character’s camera and there are not much setting I have adjusted. The only options that I did adjust are the options following
- Current focal Length - 10
- Manual Focus Distance - 300cm
- Use Pawn Control Rotation
However I don’t think that will be the issue that cause this happen since I have redo the character blueprint again with default setting and it will not functioning
- The value of Trace Distance is 400 value
I have try to work on different value for this float variables but still not resolve this issue
I’m very sorry since I’m new user so I am not allowed to upload the screen recording video and too much media.
my crosshair which is the center of my scene
The trace looks fine, how are we drawing it? HUD? Widget? Something else?
line trace is not following along my crosshair
Is it safe to assume these are 2 completely independent entities? As in: you trace some, and then draw a crosshair based on some other data? Rather than trace → draw crosshair where you actually traced?
Asking, as there are many ways to approach this kind of thing. FYI, the default template in UE4’s fps template is using a wrong offset for the crosshair, for example.
Hi Thank you for the response:
-
The method I assignedCine Camera is add this camera actor in this blueprint, then drag the variable which to get the reference
-
I did adjust to lower down as well as increase the value of the float “Trace Length” but it seem doesn’t have any changes in my scene.
-
The collision responces that you mean is object collision?
The method I used to identify the trace line is using the line trace color to red and set the Debug Type either One Frame or Duration only then I notice the line trace is not following what I have pointed in my scene.
Since I was working on a interior scene therefore I didn’t notice how the line goes wrong but when I move to a brand new scene I can see the red line trace is invert with my input axis.
What does it mean? When you pan left the trace goes right?
The method I was working on this is I generate the line trace in my character controller and
choose the debug type to duration to check on the line trace but the crosshair is using widget on the scene.
The widget is set at the center of the scene and I was assuming the line trace is following what I am pointed just like how people usually work on the line trace the line trace are always follow the input as well as where the player was pointing. I did follow some of the youtube tutorials and the outcome is what I expected but not function in my scene
Youtube Tutorial link:
Yeah, that is what I mean when I pan to left the line trace to right kinda weird the input is totally inverted
You sure? The whole thing is wonky:
That’s all we can see with what you’ve presented so far.
- how is the widget drawn - I feel it’s not drawn at the center of the screen at all. I might be wrong, it might be a screenshot / dpi thing.
- can we see the actor hierarchy - especially the camera - the way it’s attached / offset somehow?
Yeah I sure since I am new user and I can’t upload the video and media here therefore I snap this screenshot so the proposition have some problem in this image
Is this in the controller? How are you getting the hold of the camera then?
but the crosshair is using widget on the scene.
Can we see how you do it? Do you account for widget size?
Sure this is the camera Hierarchy in my character class of Blueprint
I am working on the line tracing on my character class Blueprint and add the camera on the character then I create the blueprint based on the image that is provided at above
Looks fine. And the widget? How is it drawn? And the widget hierarchy?
All those question are here because what you’re telling us does not line up with what we’re seeing. There’s more that is happening where we cannot see.
edit: Nah, turns out it’s right there in the first pic. I’m just blind.
For example, the most rudimentary and straightforward method would be:
- an anchored image:
The Crosshair Widget I just assigned the box with the middle anchors and adjust the alignment to x: 0.5 y:0.5 to make sure the cross hair stay at the middle on the screen. The resolution of canvas is 1920*1080 that fit with my screen size. Below is the widget hierarchy for my crosshair I just use a canvas that fit the screen size and use horizontal box to size with my image content then children my image in the box
Is the image filling the horizontal box somehow? Do we need a HB here?
Could you also clarify this:
Are you sure this in the controller - not in the character?
Yeah that kinda weird since I have anchored the cross hair image and it just call the crosshair widget after click on the start button but the main problem is while I pan to left (mouse move to left the line will trace to right so the mouse input is totally inverted to the result)
As the crosshair at from my side just function for user to identify where they are pointing so the crosshair is not following along with the line trace. I was expected the line trace will be keeping on the center but I saw the line trace on ur side is keep on following the crosshair. Are you using some method to affect the crosshair to following the line?
100% of the script is in the pic. There’s nothing to follow, the widget sits in the middle.
I can’t even wrap my head around:
the main problem is while I pan to left (mouse move to left the line will trace to right so the mouse input is totally inverted to the result)
This. Curious. I even replaced the cam with a cine one (sensing a bug, mayhap) but it works fine.
Is Character class blueprint not controller
I am very sorry about this that is my bad for the wrong presentation
Is you char using Control Rotation?