TPS: Muzzle boom to collision tracked by crosshair

Is it possible to put a boom from the end of a barrel that extends to first collision (or set distance if not collision) and then have a crosshair move about the screen tracking it?

I am creating a TPS and I am wanting to also swap camera from left to right shoulder which I have figured out, but this causes issues with my crosshair and my above question is how I would like to go about resolving it, if possible.

Thanks!

Are you familiar with traces? If not, you might want to look them up. They are insanely useful and there are many kinds.

You can set up a trace that runs from the end of your gun component to X amount of distance away from it’s forward vector. When it hits something, it returns something called a hit struct. You can split this struct up into a many different things, one of them being the hit location of what it just hit (which will be a vector).

You can then plug this vector into a node called “Convert World Location to Screen Location” which will give you 2D coordinates for you to use in a UMG widget or HUD BP for your crosshairs.

Thanks! I was able to follow the idea and will look into the steps of that process!

No problem. Be sure to sure to mark my post as the answer if it answered your question. Otherwise, let me know if you have any other questions.