Quick Question about DeltaTime and Speed location

Is there any reason why we wouldn’t want to add in our movement speed and DeltaTime like this?

AddActorLocalOffset(deltaLocation * movementSpeed * UGameplayStatics::GetWorldDeltaSeconds(this));

If the Y and Z members of the FVector are zero, then we’re not really worried about those getting changed by multiplying the entire FVector by DeltaTime and Speed, but IF we wanted to later add in Y or Z movement (like if we were making a top-down Zelda or whatever and assuming that we weren’t trying to make it feel tank-like), wouldn’t we want speed and DeltaTime to apply to the entire movement Vector rather than just the X-axis? Or maybe it’s my old Unity mindset messing with me lol, I’m sure under the hood the way Unreal processes these things is different.

You mean instead of this

DeltaLocation.X = Value * Speed * UGameplayStatics::GetWorldDeltaSeconds(this);
AddActorLocalOffset(DeltaLocation); 

have

DeltaLocation.X = Value;
AddActorLocalOffset(DeltaLocation * Speed * UGameplayStatics::GetWorldDeltaSeconds(this)); 

this? If that’s what you mean then I’m not quite sure what the point is. You already know those values are 0 but then you’re changing the code so that you’re multiplying those two values by some expression, so just have a complicated way of setting them to 0 unless the compiler sees that and optimises the code to what it was before.
If you do decide later to have Y and Z to also be modified then that’s a very trivial change to make.

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

Privacy & Terms