Had to set Open Angle to 90.0 and Close Angle to -90.0 in order to close doors.
With Close Angle 0.0 the doors do not close.
Yeah I had a similar problem, my door was behaving very strangely until I saw that when it was closed was at 90, and when open it was set to zero. Took me a few minutes to got around to looking at the value in the UE editor with the door closed.
In the end, these values just depend on which side of the floor you started with the doorwall. Sounds we went on opposite sides of the one Ben started with.
Recheck the code or put it here as you really shouldnt be having to use aan 180 degree arc to achieve 90 degrees of movement regardless of the side of the map you are facing when you place the door.
The -90 over 90 happens to most i think as something changed in the orientation when setting up a new project.
This will cause you issue in later sections when applying the smooth closing of the doors lectures if not resolved.
Any help needed let me know.
Take a look on rotation of the object inside of editor, because depending of the angle what you put the door inside of the world, this will change in code.
For Example in my code I need to change the close value to Yaw 90.0f.
We all put our doors in a different wall then Ben did, eh?
Here was my solution. I just created a private FRotator called InitialDoorAngle and then set it in the Super::BeginPlay() method to the initial angle the door is at in the editor.
// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
ActorThatOpens = GetWorld()->GetFirstPlayerController()->GetPawn();
Owner = GetOwner();
// Get the initial door angle (closed angle)
InitialDoorAngle = Owner->GetActorRotation();
}
Then when the close door method is called you just do this:
void UOpenDoor::CloseDoor()
{
Owner->SetActorRotation(FRotator(0.f, InitialDoorAngle.Yaw, 0.f));
}
It’s a bit easier and nicer looking than using two different door angle variables and solves the problem of multiple doors facing different ways!
Thank you. This code worked well for the 4 doors I had, each on separate walls.
For the OpenDoor() function I used a FRotator of 0.f, 0.f, 0.f