What is the purpose of removing the code associated with the LastDoorOpenTime and DoorCloseDelay variables?

Hello all, so what is the purpose of removing the code associated with the LastDoorOpenTime and DoorCloseDelay variables? I know Ben said it is to remove code that is being superseded by the Blueprint, however it really is not (at least not easily), as the OnOpen and OnClose define how the door is opening/closing, but does not allow for a delay between when the door opens and when it closes… However if you leave the following associated with the code, then you can literally play test the game to have the door slam in your face still. The code block is as follows:

From OpenDoor.cpp

//Poll the Trigger Volume

if (GetTotalMassOfActorsOnPlate()> TriggerMass)
{
	OnOpenRequest.Broadcast();
	LastDoorOpenTime = GetWorld()->GetTimeSeconds(); //Advised to get rid of by Ben
};
if(GetWorld()->GetTimeSeconds() - LastDoorOpenTime > DoorCloseDelay) //Advised to get rid of/alter by Ben
{
	OnCloseRequest.Broadcast();
}

}

From OpenDoor.h

UPROPERTY(EditAnywhere)
	float DoorCloseDelay = 0.f; //Advised to get rid of by Ben

float LastDoorOpenTime; //Advised to get rid of by Ben

Thanks, and I hope that someone can help clarify this!

From what i gathered, the reason was because if you set the timer on the animation to 2 seconds to open/close the door, it wouldn’t try to do it in the 1 second, or .5 seconds that i had it set to. So basically, it was so that the door could run it’s reverse course in the blueprint within the time allotted. Perhaps if you want to shut the door in your face, as it was hard coded, you could simply change the time frame it takes to open/close the door. That way you still get the effect of it slamming in your face, but you also get the cool animation that comes with it and no hard coding.

Thanks for the help. I think that would make sense, however I went and played with the variables after the fact, and it appeared that the door was opening and closing as controlled by the blueprint, but the delay between when the door finishes opening and when it starts to close was controlled by the DoorCloseDelay. I know Ben said it was a good idea to get rid of the hard coded function because it was being controlled in 2 places which could understandably get very confusing, but to my mind it is still controlling a separate variable. Or am I misunderstanding something?

I could be mistaken, but i think the logic as you are saying it would look something like this:

// Stand on pressure plate
// Door opens (takes 2 seconds per Timeline in Blueprint)
// Door stays open as long as you’re on the plate
// Step off pressure plate (LastDoorOpenTime/DoorCloseDelay kicks in takes 1 second and Closes door)
meanwhile at the same time
// Step off pressure plate (Blueprint Timeline is trying to animate the door to reverse its rotation to close within a 2 second timer)

So, i can’t see what you’re seeing, but i’m guessing with both of those codes active, it’s shutting quickly after getting off of the pressure plate. However that animation is still running for 1 more second. Which just sounds like it would leave a whole lot of room for errors or glitches. If that’s the look you’re going for though, then maybe try creating an entirely different close door function, instead of running the open door in reverse. (i’m new to all of this, so i can’t say if any of this is accurate or would work. Just using logic at this point. lol)

Fair enough… I just occurred to me that I should probably just try setting DoorCloseDelay at 0 and see if it acts as I think it should (open as soon as I step on the pad, close as soon as I step off)… That may lead to the glitches that you are mentioning… I will have to try that later.

Thanks again! I will let you know what happens.

1 Like

So it looks like it is in a way controlling the length of the animation, however it is controlling the length that the animation in on. So for instance, with the DoorCloseDelay set at 0, the moment you step onto the pressure plate, the door starts to open, but the moment you step off, it seemlessly appears to be going to the reverse animation, irregardless of whether the forward/opening animation is done yet… Thus if you have the delay set at 3, if you step on the pad and step off, there is a 3 second delay between the moment you step off and the door closing, and if you have a delay of 0, then the door is only opening while you are standing on it… So I guess that you are controlling the animation time with the code, but this code is superseding the blueprint.

Thanks again for the help!

Privacy & Terms