In our project, we will have many identical static meshes which are being handled by an instanced static mesh component. However, one type of mesh can be triggered to move. An actor, hidden in game, exists for each instance of this mesh. The actor has a component with an OnUpdateTransform method which calls the instanced static mesh component’s UpdateInstanceTransform with the instance index of the actor’s parallel instanced mesh. See code below. This causes the instance to mirror the actor’s movements.
This works as expected in PIE (with and without Android set as the preview platform, unlike the bug mentioned in https://forums.unrealengine.com/t/ue-5-4-facing-a-bug-relating-to-ism-on-android-platforms-and-android-platform-preview/1826137 ). It also works as expected in win64 packages. However, in Android packages, every instance OTHER than the instance index passed to UpdateInstanceTransform is also affected. Either they disappear, or their transform is updated in the same way (it’s hard to tell).
Does this happen to be a known issue, or is there something that can be done to fix it?
Thank you!
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "ISMUpdaterScene.generated.h"
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent))
class ISMUpdaterScene : public USceneComponent
{
GENERATED_BODY()
ISMUpdaterScene();
virtual void OnUpdateTransform(EUpdateTransformFlags updateTransformFlags, ETeleportType teleportType) override;
public:
//Reference to ISM Component
UPROPERTY(EditInstanceOnly)
UInstancedStaticMeshComponent* m_grateInstancedMeshComponent = nullptr;
//Instance ID for ISM mesh instance
UPROPERTY(EditAnywhere)
int32 m_instanceID;
};
------
void ISMUpdaterScene::OnUpdateTransform(EUpdateTransformFlags updateTransformFlags, ETeleportType teleportType)
{
FTransform xform = this->GetComponentTransform();
Super::OnUpdateTransform(updateTransformFlags, teleportType);
if (m_grateInstancedMeshComponent)
{
m_grateInstancedMeshComponent->UpdateInstanceTransform(m_instanceID, this->GetComponentTransform(), true, true, teleportType != ETeleportType::None);
}
}