Performance question?

Hello,

I was wondering if moving to c++ would make a difference on using timelines, vector lerps and updateing locations

Testing with around 200-400 BP in scene at runtime and it takes around 2-5 Ms, so before i want to spend any time converting to c++ i was wondering if there would even be a difference?

Just tested it with 1024 actors oscillating up and down.
With BP version, the game thread took 18 ms.
With C++ version, 16 ms.

So you can win some performance by making it in code.

1 Like

You could also save some performance by disabling tick on all of them but one and have that one handle the movements of the rest. (In cpp)


A quick test:

  • Total Spawned: 4096

Bounce

  • CPP: class updating function of the spawned hover actors:
    image

  • CPP: Each spawned hover actor with tick:
    image

  • Blueprint (empty) inheriting from hover cpp class, each with tick:
    image

  • Blueprint with timeline (tick disabled):
    image


The blueprint:

Hover function (cpp)
void AHoverTestActor::ActorHover(float Value)
{
	DrawDebugPoint(GetWorld(), GetActorLocation(), 4.f, FColor::Red, false, -1.f);
	if (IsValid(CurveFloat))
	{
		float CurrentProgress = TimelinePercent + Value;
		TimelinePercent = fmod(CurrentProgress, TimelineLength);
		float CurvePercent = CurveFloat->GetFloatValue(TimelinePercent);
		FVector NewLoc = FMath::Lerp(StartLoc, EndLoc, CurvePercent);
		SetActorLocation(NewLoc);
	}
}
1 Like

Hey @FlinnNew, everyone went over most everything already. Just came to second the notion @AntiGravity put out that if you are really trying to drill down to data oriented design altogether you can save insane amounts on performance. The Mass system is going to be perfect for these applications sometime soon, but it’s still very much in the early stages for now! Here’s some docs if you wanted to play with it!

Overview of Mass Entity in Unreal Engine | Unreal Engine 5.0 Documentation.