Wrote my code different during challenge

edit: I realized that Ben wrote his to keep the door open for a time scope so the player would have time to run across the room and escape, but mine slams shut immediately. I put my trigger box next to the door; however, because I want doors to open the same way they do in games like “The Witcher”.

//now irrelevant (should use my rubber duck more often)
Is there anything wrong with me using an “else” to finish up this “if”? I play tested it, and it works exactly how I wanted. But my whole level is very divergent from the videos. My code is below. Please let me know if there is a problem with this method.

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if (PressurePlate->IsOverlappingActor(ActorThatOpens))
	{
		OpenDoor();
		LastDoorOpenTime = GetWorld()->GetTimeSeconds();
	}
	else 
	{
		CloseDoor();
	}
}


//close door method
void UOpenDoor::CloseDoor()
{
	Owner->SetActorRotation(FRotator(0.f, 0.f, 0.f));
}
1 Like

Privacy & Terms