Hi,
I am fairly new to Unreal so I am still trying to get my head around things. I am trying to do a simple fixed camera (think of the old resident evil style games) demo at the moment.
However, I have hit a slight snag with my player when it comes to aiming. I have been building off a third person template and I got the player firing ok in third person. However, when I switch to my static fixed camera’s the player always fires at a point on the floor in the middle of the camera. This is because I am using GetPlayerViewPoint() in player controller which is getting the location and rotation of the camera. However, I want it to get the use the location and rotation of the player actor itself, so that the player shoots in front of itself.
I have had a look at using the GetActorEyesViewPoint, however, this seems to produce a result where the path for the shooting is where the mouse cursor is. Perhaps, this is the right method to use given the fixed camera’s? and I just need to restrict the yaw of the camera to ensure they shoot straight?
here is what I currently have:
FVector ADemoWeapon::GetAdjustedAim() const
{
ASPlayerController* const PC = Instigator ? Cast<ASPlayerController>(Instigator->Controller) : nullptr;
FVector FinalAim = FVector::ZeroVector;
if (PC)
{
FVector CamLoc;
FRotator CamRot;
//PC->GetPlayerViewPoint(CamLoc, CamRot);
////////////////////////////////////////////////
// Changing to get actor eyes view point aims at the mouse location
//////////////////////////////////////////////
PC->GetActorEyesViewPoint(CamLoc, CamRot);
FinalAim = CamRot.Vector();
}
else if (Instigator)
{
FinalAim = Instigator->GetBaseAimRotation().Vector();
}
return FinalAim;
}
Any advice/help would be greatly appreciated.