I’ve been having an issue on my game where the projectiles shot are going slightly to the right of my crosshair. I’m currently using an arrow to decide where my projectiles are launched so should I just keep adjusting the arrow until the projectiles align with my crosshair or is there a better method to make my projectiles shoot in the crosshairs direction?
Depends on the starting position of the projectile. If it’s not already centered on the crosshair, then you’ll get different results based on how far you’re shooting. No amount of adjustments will make it look right. If it looks good at close range, it’ll look off at long range and vice versa.
So you have two options. Either set the projectile’s starting position to be in line with your crosshair. Or find the shortest distance from A) the target position that your projectile is going to go AND; B) a line trace from the crosshair going forward to an obstacle (ie. a wall). Set that target as the AimTo position of projectile. You can use the node FindLookAtRotation to set the rotation of your projectile.
Thank you for an answer but is there any sort of tutorial or video you can recommend that can show me how to do this? I just started learning this stuff recently so I’m not exactly sure how I’m supposed to add what you recommended me into my blueprint.
I’d recommend doing a line trace from your projectile to a point in the direction of your projectile. Like 1000’s of units ahead. Also do a line trace from the crosshair directly into the view. Then you can see the difference between the two. Where they intersect is where you want your target to be. BUT, if the crosshair line trace hits a wall BEFORE the intersection, that point is what the target of your projectile should be.
This is all basic trigonometry. But there are tons of helper functions. I gave you one in my previous comment FindLookAtRotation.
There are TONS of videos on doing line traces.
This video looks like the issue you’re having. But it’s really long. Maybe it’ll give you some ideas. I’d still start with a simple video on line traces. There are tons of them on youtube.
Appreciate you for coming back with the video suggestion, I’ll definitely take a look at the video and see how I can use it in my game!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.