Efficient way of rotating UPaperGroupedSprite Instances

Hey guys,
I have quite a lot of instances of a UPaperGroupedSpriteComponent (up to millions). Now I want to change the rotation & size of all of the instances in an efficient manner, maybe even every frame if possible.

How do I do this best?

I saw the UpdateInstanceTransform function, but it gave me errors (see comments), so maybe it would be nice if you could give me some hints on how to use it. I also thought about rotating the Sprites in the Vertex shader but I dont know which shader is used for the sprite rendering.

Thanks a lot!

in fact, I get an exception at the last line and I dont know why :confused: any help would be much appreciated!

	FVector CamPos;
	if (SpriteComponent->GetInstanceCount() < 1)
		return;
	if (!GEngine)
		return;
	else
		CamPos = GEngine->GetFirstLocalPlayerController(GetWorld())->PlayerCameraManager->GetCameraLocation();

	FTransform pTransform;
	SpriteComponent->GetInstanceTransform(0, pTransform);

	FVector NewTranslation = pTransform.GetLocation();
	FRotator NewRotation = FRotationMatrix::MakeFromX((CamPos - pTransform.GetLocation())).Rotator();
	FVector NewScale = pTransform.GetScale3D();

	auto numElements = SpriteComponent->GetInstanceCount();
	for (int32 idx = 0; idx < numElements; idx++) {

		if (SpriteComponent->GetPerInstanceSpriteData().IsValidIndex(idx)) {
			
			const FTransform NewTransform(NewRotation, NewTranslation, NewScale);
			SpriteComponent->UpdateInstanceTransform(idx, NewTransform);
		}
	}

SpriteComponent->ApplyWorldOffset(vec, false);
SpriteComponent->AddWorldRotation(rot);
give exceptions as well. Can someone help?

Regarding the error/crash of UpdateInstanceTransform etc., this has solved the issue: