Question about Actors and visibility in Editor vs in-game

Hey all,

So finally diving into actual UE4 C++ coding after many years away from the fold. And I have a question.

I’m starting work on a conversation system and I’m looking into how you’d go about creating a ‘stage’ for placing actors on.

Functionally, it works like this:

  • We have a container ‘object’ that contains a set of ‘markers’ that Actors can be bound to.
  • There can be 1-n number of ‘markers’ on that stage object.
  • Each of those markers can be moved, rotated in-editor but are not visible in-game.

My first guess at implementing this is that the stage is derived from an Actor, as well as each marker node. My question is how do we set these markers as visible in-editor only? I see that you can set the bitflag to be bHidden, but I’d like to disable the editor from changing that.

-Ash

In BP there is a option called “Hidden in Game”.
AActor has a member called “bHiddenEd” that may be what you are looking for.

I don’t know if you know this, But there is a chm with API info in it in the documentation folder of the engine.

HTH

-Edit-
I see that the “bHidden” member of AActor says “Allows us to only see this Actor in the Editor, and not in the actual game.”

-Edit2-
I see you found the bHidden member.

You could reset that bit on the [BeginPlay] method, But why do you want to disable the editor from changing that?

Just for the record, there is indeed a clean solution; your Actor needs simply to implement the IsEditorOnly() virtual method and return true;

See AnswerHub: Is there a way for “Editor only” Actors?

Edit: sorry, I missed the point of the OP, indeed!

That’s more for tools though imo. If he did that, his actors would not spawn and thus his conversations would not work.

As @ryan20fun said you can use the ‘Actor Hidden in Game’ toggle on any visible componant (static meshes, billboards, etc).
To disable it from being changed, implement the following function:



.h
virtual void OnConstruction(const FTransform& Transform) override;

.cpp
void AMyActor::OnConstruction(const FTransform& Transform)
{
    Super::OnConstruction(Transform);

    MyComponent->bHiddenInGame = true
}


OnConstruction runs any time any value is changed, allowing you to modify actors in the editor. The above will automatically set it to hidden every time, even if someone tries to inhide it, it will be set back to hidden.