Dynamic door open for flexibility

This is the first time I’ve shared here despite persistent prompting (sorry Ben).

I didn’t like that moving the door later in the project could break the function, so I added a line to make the door open correctly when moved, without relying on the doors initial Yaw.

Seems to work pretty well, but I am a total newb at C++ so if someone could tell me whether this is the best method, I’d appreciate it. Is there a reason Ben didn’t use ‘Set Relative Rotation’ instead ?

void UOpenDoor::BeginPlay()
{
Super::BeginPlay();

AActor* Owner = GetOwner();
FRotator OldRot = Owner->GetActorRotation();
FRotator NewRotation = OldRot + FRotator(0.0f, -70.0f, 0.0f);
Owner->SetActorRotation(NewRotation);

}

3 Likes

That’s what I was looking for thank you !

Privacy & Terms