Searched a bit, a lot of round-a-bout discussion but nothing direct to what I am looking for.
3rd person game, zoom-in aim mode where crosshair appears.
Crosshair is not centered and located down from center a bit.
Using a camera > GetWorldRotation>GetForwardVector x distance setup to find the end point (for line trace)
Obvious issues are alignment breaks depending on how close you are, and end point is calculated based on camera look.
Goal: How do I get vector for the direction exactly behind my offset crosshair so both issues would be solved and I can freely move my crosshairs anywhere?
I’m not the biggest fan as I have to manually input the offset into the blueprint whenever I change the reticle location vs. having it update automatically. (Picture a non fixed cursor that is shooting all around the screen).
This is really good stuff. Thank you. I haven’t tried it yet since I’m mobile but a quick question: is your image 66 part of a canvas widget? I’m assuming the whole widget isn’t a full 1920x1080 resolution, since it looks like in this scenario you are setting the position.
For both canvas slot position and render transform translation I’m having a hard time latching on to the image asset in the widget. Keep getting this error message:
Yeah, just an image on a canvas. It’s weird to use 1920x1080, but it works for all viewport sizes; though, it doesn’t hit the right & bottom borders unless the aspect ratio is the same.
Yeah, but I tested the same thing with a widget, too, and it worked (I kept the image at (0,0) in the widget); an image is a widget, also, so they both work the same, so you just need to get the widget itself, not anything inside it. Alignment is the pivot point of the widget, which is the origin of it, so setting it to (0.5, 0.5) moves the origin to the center of it.
As for which to use (canvas slot position or render transform translation), the canvas slot position sets the position of the widget directly, whereas the render transform translation offsets the widget from its location, so render transform translation only works if the widget is at (0,0).
It works perfectly and reaches the borders of any viewport size (which means it’s accurate). Make sure the center of the target is at (0,0) in the widget.
So, I’m just coming back to this after a few days and I don’t think it was working as I thought it was.
Video of issue:
Reticle Setup - as you can see from the vid it appears to be going to 0,0 on the 1920x1080 canvas. Same thing if the reticle image inside the canvas is at 0,0 OR in the center:
While my cursor isn’t moving around on screen like yours, it is off center so there is something in that mix that isn’t working correctly. Thought I would try you one more time
Edit #1 For the record for anyone looking at this post, the reason I want to use the reticle as the endpoint, rather than a hardcoded setup like this:
(This is how I setup my last example) First, your reticle image isn’t located at (0,0) because it’s not in the top-left corner (where (0,0) is at). Second, you need to set the image’s alignment to (0.5,0.5) to make the center of the reticle the origin. This will make the position of the widget the center of the reticle.
Then in blueprint (though, you can also do this in the widget), you set the widget’s position directly using a variable & “Set Position In Viewport”. This makes “getting” the widget’s position easy because we already have it stored as a variable (i.e. we don’t need to get the widget’s position, just use the variable). Same picture from my last post
The reason I chose this way is because the setting positions is perfectly accurate to the pixel.
Then, in your third picture, you need to push that point forward using the direction just like you did here:
In that case, you need to first trace from the camera/reticle to the world, and wherever that point hits is where the character aims. Then, when you shoot, the gun trace goes from the character’s gun to that point. That way, the character always aims at what the reticle is on.
Obviously, you only want to aim at it if it’s in front of the character.
Got it! Yes! The game changer here was using the Deproject World Position as the starting point rather than the socket location on the gun.
However, I STILL don’t understand why the other way didn’t work though…logically its a straight line from the socket to the same deprojected reticle to world space end point.
Regardless, your setup allowed me to freely make reticles and just auto-place them with a few nodes in the blueprint so big efficiency gain there too. You’ve been a big help midgunner.
But I think there may still be an issue with making the starting point at the camera/reticle. For example, if the character’s weapon is blocked by something (like when hiding behind a wall), they will be able to shoot through it since the shot is coming from the camera rather than the weapon.
Actually yeah that’s a good call. It’s not a problem for projectiles because I’m just using that line trace to get the endpoint and then I go ahead and fire the projectile so the wall will still block it on its way to that endpoint. However for line trace instant weapons you’re right it would be skipping right over the actual traveling distance.
Perhaps I will revisit doing a line trace from the socket to the endpoint again.