How to Aim with fixed camera

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.

Actually the way, the function works, it will try to use any active camera and default to the characters camera eyes height.

If you look inside your blueprint or c++, the variable “Base Eye Height” (category Camera) needs to be set as that is the default position for that function. Make sure you have that set correctly for your character.

By default, the Eye height will only accept a height, you can override the function in c++ and put any (X,Y,Z) offset you want. You can even put a socket representing an eyes location that is aligned to the player’s head bone.

Hope that helps =)

thanks for the help; much appreciated