For this I am using the character model from the first person template and I’ve slightly modified the gun and projectile.
I got the line trace portion of the code online and I understand most of it except for the camera manager part. Why use get player camera manager to get the player’s location? Why not the player controller? Also, why does GetActorLocation give me the exact center of the screen, where my cross hair is? I tried moving the camera and mesh around but the trace still goes towards the center. Why isn’t it affected by the positions and sizes of the mesh components?
Lastly, I am trying to make a class called Weapon (which is derived form Actor) and two derived classes: projectile and hit scan. Both will need the line trace so I want to put it in the Weapon class. But I am having trouble figuring out how to use the get player camera manager and line trace function.
In the APlayerCameraManager there is no GetActorLocation and geActortForwardVector so how do I get both of these values in c++.
For the trace, would this code be correct?
UWorld::LineTraceSingleByChannel(...)