I`m trying to make bullet manager. I made a simple C++ class with single static mesh instance in it to represent bullets with. Then I created a BP based on that class. When I manually add some elements and try to move them it does not refresh their position in the editor every frame but only once when I compile blueprint.
On the other hand when I add static mesh instance component from blueprint menu it works as usual - every frame locations of elements are updated.
.h
public:
AProjectileSpawner();
protected:
virtual void OnConstruction(const FTransform& Transform) override;
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category = "Settings")
USceneComponent* DefaultSceneRoot = nullptr;
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category = "Settings")
UInstancedStaticMeshComponent* StaticMeshInstance = nullptr;
};
.cpp
AProjectileSpawner::AProjectileSpawner()
{
PrimaryActorTick.bCanEverTick = false;
DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
RootComponent = DefaultSceneRoot;
StaticMeshInstance = CreateDefaultSubobject<UInstancedStaticMeshComponent>(TEXT("ProjectileStaticMeshInstance"));
StaticMeshInstance->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
}