How do I make my bullet go to my crosshair?

So, I have a Crosshair in the direct middle of my screen. I have a weapon set up that when I fire, it will use the spawn actor class node to spawn in the bullet. The only problem is, that the bullet goes where ever my gun is facing because the bullet is coming out of the socket. How would I make my bullet go to my crosshair? Would I have to use a line trace? How would I use a line trace? Help is appreciated! Thanks!

While you can draw a trace you don’t need to in this case. Within the event tick set a custom variable “mouse location” by using:

‘get player controller’ → ‘get hit result under cursor by channel’ → ‘break hit result’ → ‘set’

You can now use the custom variable location along with the location of where the projectile is spawning to help build a transform for the ‘spawn actor’ node:

‘find look at rotation’ → ‘make transform’ → ‘spawn actor’

Plug the projectile spawn location and mouse location into “start” and “target” pins respectively on ‘find look at rotation’ node. Plug the projectile spawn location and the result from rotation node into “location” and “rotation” pins respectively on ‘make transform’ node. Should give you the correct transform.

Can you show me a blueprint of this?

In this project the ‘sphere’ object is where the projectile spawns.

Hello! I am just wondering about if I can get the bullet to come out of my socket. If so how?

Hello! Is there any way to make it where the bullet comes out of the socket. Would I have to get the socket location. If so how?