Using DeltaTime vs GetTimeSeconds

I think I am posting under the correct lecture…

In Lecture 112 of the c++ Unreal course we are introduced to the function GetTimeSeconds to add a delay to the doors closing. Is there any reason we don’t use DeltaTime instead and count up the delay?

if (PressurePlate && PressurePlate -> IsOverlappingActor(ActorThatOpen)){

		OpenDoor(DeltaTime);
		DoorLastOpened = 0.f;
	}
	else if (DoorLastOpened > DoorCloseDelay){
		CloseDoor(DeltaTime);
	}
	
	DoorLastOpened += DeltaTime;

In programming, there are almost always more than one way to solve a problem. Adding up DeltaTime could certainly work. I think the point is that they are gradually introducing you to other ways to solve problems with the API functions, and to encourage you to explore the API available.

1 Like

Thanks for the reply! I had a feeling this was the case but wanted to make sure there wasn’t some behavior with DeltaTime that I wasn’t aware of that made using the API function better practice.

Right, you’d simply have to sum the delta time as you progress and making sure you’re opening or closing doors appropriately based on that summative variable info. Picking one or another, may change the functionality required to implement the code function though. You should try it that way just to see if you can figure it out, great way to learn.

1 Like

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

Privacy & Terms