Two doors on separate walls

Hello,

So, I put two doors on two separate walls.

When I SetActorRotation(), the rotation seems to be set in the global axes, making the door on the left open past 90 degrees.

So, I tried this:

AActor* Owner = GetOwner();
FRotator NewRotation = Owner->K2_GetActorRotation().Add(0.0f, 0.5f, 0.0f);  
NewRotation.Clamp();
Owner->SetActorRotation(NewRotation);

Got both doors to rotate from their initial positions but am unable to stop them.
I think I can use clamp() but not sure how, although I suppose I can use an if statement to stop the rotation (still doesn’t solve the door on the left because it will stop at the given global angle and also there may be a smarter way to do all this).

Maybe the following lectures will address this issue.

EDIT: I feel stupid :slight_smile:

UPROPERTY(EditAnywhere)
float OpenAngle = 90.0f;

UPROPERTY(EditAnywhere)
float CloseAngle = 90.0f;

FRotator::Clamp clamps the value between 0 and 360. You can use FMath::Clamp instead

NewRotation.Yaw = FMath::Clamp(NewRotation.Yaw, 0.f, 90.f);
1 Like

Thanks.

Got caught up watching E3 yesterday :slight_smile:

The FMath::Clamp is working as intended for the door on the right but the left is still opening to 90 degrees in the world coordinates.

Maybe I have to make the door a child of the wall and rotate locally?
I’ll just go ahead with the lectures for now and come back for it.

EDIT: I realized I might be able to just add a property for this. Will find out.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms