# Raycasting in C++?

**URL:** <https://forums.unrealengine.com/t/raycasting-in-c/595298>\
**Category:** C++\
**Tags:** Raycast, casting, unreal-engine, UE4, question\
**Created:** [July 2, 2022, 2:04am UTC](https://forums.unrealengine.com/t/raycasting-in-c/595298 "2022-07-02T02:04:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShadowSprite123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ShadowSprite123](https://forums.unrealengine.com/u/ShadowSprite123)\
**Post date:** [July 2, 2022, 2:04am UTC](https://forums.unrealengine.com/t/raycasting-in-c/595298/1 "2022-07-02T02:04:54Z")

</div>

Hi! I don’t know if I’m doing this somewhat right or if I’m completely wrong but I wanted to know how I should go about this:  
1.Should I shoot the raycast from the player class and just attach the gun.  
2.Or should I implement raycasting in the gun’s actor class and call it from the character.

And for which ever option it would be nice if I can get an example cause I’ve tried implementing both ways and it doesn’t seem to work. Also, if you need me to include the ways I’ve implemented this I can only show option 1 cause I reset the code and I don’t wanna rewrite it again.  
This is for Unreal Engine 4.27.2

And thanks in advance.
