I encountered a problem when following the course’s code for opening and closing the door, because my door starts at 90 degrees (because I put it on a different wall). I fixed this and this code should work for any upright door, whatever the start yaw angle:
in the private section of the OpenDoor.h file:
UPROPERTY(EditAnywhere)
float OpenAngle = -90.0f;
float ClosedAngle;
in the constructor of OpenDoor.cpp:
ClosedAngle = GetOwner()->GetActorRotation().Yaw;
OpenAngle += ClosedAngle;
and OpenDoor and CloseDoor functions:
void UOpenDoor::OpenDoor() {
FRotator Rotation = FRotator(0.f, OpenAngle, 0.f);
Owner->SetActorRotation(Rotation);
}
void UOpenDoor::CloseDoor() {
FRotator Rotation = FRotator(0.f, ClosedAngle, 0.f);
Owner->SetActorRotation(Rotation);
}