Trying to get camera rotation

Im learning how to code on c++, and I have a doubt that I cant find the answer.
So I create a weapon and I want to get the CameraRotation from the component camera of my character…

	AActor* MyOwner = GetOwner();

	if (MyOwner)
	{ 
		AHunter * CharacterComp = Cast<AHunter>(MyOwner);

		FRotator CameraRotation;

		CameraRotation = CharacterComp.CameraComp->GetComponentRotation();
	}
}

Im getting the erro expression have a class type…

Anyone can help ?

Since CharacterComp is a pointer to AHunter AHunter* type, you may need to begin with the CharacterComp-> operator instead of CharacterComp..

I assume that if you’re using a Camera, it’s for the actual player. If you’re doing this, then you’re likely using a subclass of pawn. With this said, isn’t it better do the following?

if (CharacterComp->GetController())
{
CameraRotation = CharacterComp->GetControlRotation();
}

I write this because you say that this is for the weapon, so you want it to be congruent with the actual center point.

1 Like

I agree with this answer, when talking about rotation, camera usually is not the answer, is the control rotation what you need.