Announcement

Collapse
No announcement yet.

Actor spawning but invisible

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Actor spawning but invisible

    Hi,

    I'm spawning an actor, and in its constructor, I have the following code:

    Code:
    UStaticMeshComponent* mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FuelTankMesh"));
    
    ConstructorHelpers::FObjectFinder<UStaticMeshComponent> MeshRef(TEXT("/Game/Models/placeholder.placeholder"));
    mesh->SetStaticMesh((UStaticMesh*)MeshRef.Object);
    When I run the game, the object appears in the World Outliner and has FuelTankMesh (inherited) in its Details box, but the mesh is invisible in-game. If I drag the mesh into the game window, I can see that fine.

    Does anyone have an idea as to why this is happening?

    #2
    Several things i can think of:
    1) Maybe the mesh component is invisible? Use "mesh->SetVisible(true)" on your mesh component
    2) Maybe the mesh is there, just in the wrong location? Check if your mesh component has its attachment rules and location set up properly.
    3) Do you ever assign the "UStaticMeshComponent* mesh" temporary variable to a class member variable and/or attach it to the actor it belongs to? if not, UE4 will see that the mesh component is not assigned to any actor and removes it from the game.

    Comment

    Working...
    X