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.
asked Oct 29 '18 at 07:10 AM in Blueprint Scripting
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.
Follow this question
Once you sign in you will be able to subscribe for any updates here