# HOW To Align Weapon With Crosshair? Really Appreciate Help!

**URL:** <https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098>\
**Category:** Community & Industry Discussion\
**Tags:** crosshair, weapon, unreal-engine, question\
**Created:** [August 21, 2020, 3:45am UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098 "2020-08-21T03:45:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zSSkitzz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zSSkitzz](https://forums.unrealengine.com/u/zSSkitzz)\
**Post date:** [August 21, 2020, 3:45am UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/1 "2020-08-21T03:45:44Z")

</div>

_I’ve implemented a weapon that’s capable of firing, aiming and all that a weapon does, but I’ve ran into a big problem for me where the gun doesn’t align with the crosshair while moving, for example when you jump the weapon points straight up. I’ve set up aim offsets which help a little bit but not a big difference, and I’ve tried looking for tutorials but the code is either too messy as in nodes out of view and wires across the screen going back and forth, or they don’t help me at all. If anyone has any idea on how I could rotate the mesh and align it to the crosshair while firing the weapon would be a big help to me. I’m new at weapons and started implementing them 2 days ago._

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fa94e6df](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fa94e6df](https://forums.unrealengine.com/u/anonymous_user_fa94e6df)\
**Post date:** [August 21, 2020, 6:15am UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/2 "2020-08-21T06:15:51Z")

</div>

Instead of doing that you can shoot using raycasts. So the ray cast will come out from the center of the follow camera if you are making a FPS game. You can use particle effects to show the muzzle flash and shoot with raycasts to shoot the AI or if you are making a multiplayer game, other players.

**You can follow this tutorial:**

[Click Here](https://www.youtube.com/watch?v=5goK0_BSwMY)

---

<div class="post-metadata">

**Author:** ![zSSkitzz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zSSkitzz](https://forums.unrealengine.com/u/zSSkitzz)\
**Post date:** [August 21, 2020, 8:20pm UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/3 "2020-08-21T20:20:05Z")

</div>

_Thx for replying, the video you sent will be helpful to me but it’s not what I meant. The problem isn’t the projectiles, its the mesh/weapon itself. For example if the player jumps the socket follows the bone and rotates up for a bit then back down, I was looking for a way to counteract that. I am new to this so sorry if I’m not understanding what you say sometimes._

---

<div class="post-metadata">

**Author:** ![zSSkitzz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zSSkitzz](https://forums.unrealengine.com/u/zSSkitzz)\
**Post date:** [August 21, 2020, 10:40pm UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/4 "2020-08-21T22:40:41Z")

</div>

Forgive me for not being patient. Are you still helping?

---

<div class="post-metadata">

**Author:** ![zSSkitzz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zSSkitzz](https://forums.unrealengine.com/u/zSSkitzz)\
**Post date:** [August 21, 2020, 10:59pm UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/5 "2020-08-21T22:59:06Z")

</div>

Good News! After a bit of experimenting with find look at rotation and the line trace you showed me, the mesh aligns with the center no matter what and I subtract 90 from the z axis to rotate it from the right to the middle! Thx for your help!

---

<div class="post-metadata">

**Author:** ![Cipher5](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cipher5/32/466939_2.png) [@Cipher5](https://forums.unrealengine.com/u/Cipher5)\
**Post date:** [January 28, 2023, 6:03pm UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/6 "2023-01-28T18:03:11Z")

</div>

Hey could you post an image how you did it?

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [January 28, 2023, 9:40pm UTC](https://forums.unrealengine.com/t/how-to-align-weapon-with-crosshair-really-appreciate-help/470098/7 "2023-01-28T21:40:26Z")

</div>

In general idea for accurate aiming is this:

- trace line in forward vector of camera that goes trough cross-hair. Find where line trace has hit result.
- now you have. Origin of rifle, its forward vector, and point in 3d it should aim.
- find look at rotation for your gun.

Some things to consider:

- you are making game, above solution is mathematically accurate solution, but those not always “feel” right. Sometimes you will get weird unnatural (but correct) rotations of gun.
- if you are making first person shooter game, do not bother with accurately rotating gun. Limit maximum rotation to about 15 deg, then use aim offset to sway that gun a bit.
- Whole aiming is just cosmetic effect (like feet not sliding). Depending on your game, how advanced project is etc. Is that stuff really that important for your game, or important enough now?

So focus on game-play, movement, etc. feet placement, gun swaying, accurate animations, are usually for late stages of making game.
