Download

Changing the transform of instanced mesh instances after adding them

I can not find a way to change the transform of instances of an instanced mesh after adding them.
How can you access the instances after creation to modify their position?

All of this is in instancedstaticmeshcomponent.h

To move ALL instances at once by some delta:


virtual void ApplyWorldOffset(const FVector& InOffset, bool bWorldShift) 

To access the instance data:


/** Array of instances, bulk serialized */
UPROPERTY(EditAnywhere, Transient, DuplicateTransient, DisplayName="Instances", Category=Instances, meta=(MakeEditWidget=true))

TArray<struct FInstancedStaticMeshInstanceData> PerInstanceSMData;

Relevant part of struct used above in the TArray


USTRUCT()
struct FInstancedStaticMeshInstanceData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, Category=Instances)
	FMatrix Transform;

It looks like that API just doesn’t exist yet. I will add it to our task tracker, but do note that it will be a fairly costly operation, because it will have to update the whole transform list.

Thanks for the replies!

For now I’ll expose the PerInstanceSMData myself, but it would be great if it would be part of the public API in a future version.

I only need to update about 10 instances out of 10000 every 1 second, so the operation being costly should not make a big difference.

I added Blueprint APIs to get or update the current transform for an individual instance. This will be in 4.4

Ohhhhhhhhh thank you thank you thank you thank you.