Newb needs help!!!)

Hey guys, I’m totally new to this, no background in programming, I’m a very visual type of person, so I thought maybe the blueprint system is my chance :smiley:
I managed to create a trace and make my bullets hit the end of it, next step is to get the crosshair where I want it, which isn’t at the center of the camera unfortunately,
here lies the question: how can I do this?
My understanding is that I have to get the trace hit location, share it to HUD blueprint and project it?
If that’s correct my biggest problem is how to share that variable, thanks for your help in advance!


Where are you drawing it now (or are you)?

From memory (sorry don’t have UE4 handy here), the Receive Draw HUD Event/Node in your HUD will receive Screen X and Screen Y as parameters.

You can then use that information to calculate where to put your crosshair. Don’t forget to factor in the size of the crosshair texture itself.

You can then use those co-ordinates with a Draw Texture Node (for example) to actually do the drawing.

I’m sure there are other ways as well, but that worked for me.

Is that what you mean? Or have I misunderstood your question?

  • Mark

If you use HUD Blueprint to make the crosshair there is an handy node called : Project to Canvas. It takes a 3d vector on the scene and the output will be the 2d projected vector that you can use to draw your crosshair on the Canvas. So Basically if you want this cross hair to be draw costantly you have to spawn this trace from your weapon constantly and pass to your canvas the hit Location of the Trace, project it and draw the crosshair.

Thanks for your replies, my understanding is that something like this is possible: 42964143c2731c92482b338bb7fb73e3e77edbd1.jpeg
Or am I completely wrong?

About sharing variables, you can create a variable of type Vector called “TraceHitLocation” on your HUD Blueprint. In the other Blueprint you can create a reference to the HUD Blueprint, so you can access the variables of the HUD. The script would look like this:

In this article I show how to create a reference to the HUD.

Alright, thanks everyone!
I got what I wanted by doing what Marcos said^ Thanks, man!)
But the result wasn’t what I expected, the crosshair looked jumpy and “tick-ish”
I’m thinking it’s better to set some fixed position on the screen and deproject it, so I guess now I have to figure out how to share that trace’s variable from the HUD to the gun blueprint so it knows what the crosshair hit…

Here’s Crosshair take #2
I’m right back where I started, but with experience!
Now how do I share this crosshair variable with my gun?
Why is it so difficult, why can’t it be just copy paste from one blueprint to another? :confused:

Done! Turns out pretty easy, all I had to do was use the cast thingy.