Disable an Actor

SetActorHiddenInGame(true) will hide all components and SetActorEnableCollision(false) will disable collision on all components.

Just to note, this question seems to imply that setting an actor to hidden should disable the actor tick and all component ticks. Is that what should be happening because that hasn’t been my experience? I’ve set an actor to be hidden using SetActorHiddenInGame(true), but the actor tick continued as did the components tick. I then SetActorTickEnabled(true) in addition to hiding but this didn’t stop the components tick, I had to set components to not tick separately.

So, for clarification, if we want to disable an actor completely (ticks, collision, rendering, etc) what is the correct way to go about this?

Cheers,

I know that this is an old question, but it looks like it’s gone unanswered since then. How do you effectively completely disable (temporarily) an actor so that it doesn’t tick, generate collision events and it’s actually hidden?

I am also looking for an equivalent in Unreal Editor for Unity’s “Enabled” checkbox. I need to temporarily enable/disable actors while testing a level. It’s surprising how often I find myself needing to do this. How do you live without it?

Hello again,

Apparently, there is still no answer to this thread. Is there a simple way to deactivate a game object and activate it later? Both with blueprints and c++ API.

I’m in a bit of a similar conundrum myself, though I primarily use BP and not C++.

First things first, it’s becoming obvious to me that some form of abstraction is necessary when it comes to activating things. I haven’t seen any general functionality that will shut off tick, collision, and rendering all in one go, so that might be something you have to implement yourself.

There is an activation API in UActorComponent as shown here.
https://docs.unrealengine.com/en-US/…ion/index.html

“Should be overriden by native child classes”, it says. But it’s not exposed at all to BP and I don’t know why lol.

For my own project, I ended up implementing a generic activation component to handle this. I have various level scripts that need to be activated in a universal manner and I hate dealing with having to cast to specific classes, etc. BP Interfaces seem to have their own limitations and don’t solve the headaches I’ve had to deal with when communicating between actors and/or components. For my project, I don’t always need to mess with tick/collision/rendering, so I need that level of abstraction to activation. (i.e. Some of my actors have their tick functionality split up into different components for performance reasons, some don’t need to disable rendering/collision when they’re inactive, etc.) A similar approach could help you deal with this quickly, however, and at a much simpler scale than my use case.

So to answer your question: As far as I know, there is no simple answer. However, if you implement something smart that works for you, you can make the process simple for yourself.

You need 3 things to disable an actor:

You need to stop it from ticking. (SetActorTickEnabled(false))
You need to disable rendering (SetActorHiddenInGame(true))
You need to disable collision (SetActorEnableCollision(false))

This would make an actor essential non existent in a game. Later on you can activate all 3 to re-enable an actor.

No.

There should really be a function for that. As others said, disabling ticking, rendering and collision does not:

  • disable ticking of child components
  • disable physics
  • disable timers
1 Like

Hi.

I have struggle with this some time. I have a couple of actors that I want to be hidden from start and collision disabled. It’s no problem to hide the actor in the editor and in game from start but how do you disable collision from start without turning collision completely off?

Later I want to enable these actors and turn on collision etc.

At the moment I loop through all static mesh actors at “Event BeginPlay” and if the actor is hidden the actor is disabled with a function described above:
(SetActorTickEnabled(false))
(SetActorHiddenInGame(true))
(SetActorEnableCollision(false))

Again; is it possible to disable actor collision from start (in the editor) without turning it of completely??

I don’t know exactly what your use case is, but since it sounds like you want an actor to simply not exist, I suggest not spawning the actor.
If you’re making a level that’s too large to tick all the actors at once, consider breaking it into sublevels.
Or, better yet if the actor isn’t doing anything whatsoever, you may as well not spawn it in. Design a system for spawning actors when appropriate, rather than simply placing them all in the level at once.
As an alternative, if you’re working in a test level, it’s easy enough to move your player start somewhere else and place new actors in new areas. Doing that you can test each new actor and how it interacts with your player character independently.

Not exactly the answer the OP was looking for, but some combination of these should solve your problems.

There is also a checkbox to disable collision:

What about when you are spawning waves of the same unit? It makes sense to be able to deactivate the unit and then reactivate it once you want to spawn it again, that way you arent constantly destroying and spawning actors which sounds a lot more expensive than simply disabling and enabling them when needed. If all I had to do was:


(SetActorTickEnabled(false))
(SetActorHiddenInGame(true))
(SetActorEnableCollision(false))

that wouldn’t be too bad, but needing to disable components as well seems quite a pain, especially as you add more stuff you need to remember to disable those as well.

Sorry to bring this necropost alive, but haven’t you found a way to do that? It is insane that Blueprint seemingly has no way to just disable an Actor and its children.

Apparently Unreal Engine sucked this whole time and I didn’t even notice.

I don’t see how this functionality is vital to a game engine. Besides, it would be pretty easy to design an editor plugin that lets you disable/enable visibility, rendering, physics, and collision with the click of a button.

Are you really asking this? Of course the are times when you want to hide something, but still have it be part of the game.

You’re welcome to make your own characters.

1 Like

I do make my own characters, which look much better. Did you not read what I said? The point of what I was saying is that you cant make your own using their human creator.

The rest of your responses are as equally unintelligent. Epic are lucky most of their user/fan base are people like you.

Epic are lucky most of their user/fan base are people like you.

I think that the community here as a whole, is lucky that most of us don’t come here just to act like an ■■■■■■■.

You made your very first post on this account, to complain petulantly about things you have no knowledge or comprehension of. Why?

The “basic functionality” you are complaining that is not included in UE4, or UE5 that you point out (also not included in UE1, UE2, or UE3, I will also confirm for you) is not there, because what use does it serve? Epic has been building this specific game engine for 24 years now, and they’ve been using it to build games for 24 years now. If this “basic functinality” were useful, they’d quite likely have implemented it sometime in the last 24 years.

whatever Epic are doing, they need to get their sh*t together. this is unacceptable.

notes that Epic just bought a massive property to build their new world headquarters on, they’ve got their sh*t together

2 Likes

Haven’t tried it; but it looks like this plugin could deactivate actors:

So I elected to implement an empty class and called it HelperClass, so I can just access its static functions. The following are the methods I used, you can always extend this to disable other things you want to as well:

void HelperClass::deactivateActor(AActor* actor)
{
	// Deactivate this actor
	actor->SetActorHiddenInGame(true);
	actor->SetActorEnableCollision(false);
	actor->SetActorTickEnabled(false);

	// Call on children
	TArray<AActor*> children;
	actor->GetAllChildActors(children);			// Actual children
	actor->GetAttachedActors(children, false);	// Attached actors. Don't reset array
	for (auto child : children)
		deactivateActor(child);

}

void HelperClass::activateActor(AActor* actor)
{
	// Activate this actor
	actor->SetActorHiddenInGame(false);
	actor->SetActorEnableCollision(true);
	actor->SetActorTickEnabled(true);

	// Call on children
	TArray<AActor*> children;
	actor->GetAllChildActors(children);			// Actual children
	actor->GetAttachedActors(children, false);	// Attached Actors. Don't reset array
	for (auto child : children)
		activateActor(child);
}
1 Like

Let me argue on this.

The fact that a feature has not been implemented, does not mean that it’s because it’s useless or because the product is better without that feature.
Case in point: Blender’s ridiculous UI, beginning with the Right-Click Select.

Now let me tell you: I am using Unity since about 15 years, and I CONTINUOUSLY activate and deactivate objects in my scene hierarchy.
IT IS EXTREMELY USEFUL for a series of reasons.
If you want me to expand on this, I’ll do.

Anyway, I have a couple of basic questions on the matter:

  1. Is it so difficult to simply put a checkbox on each actor, that will it out of all the systems? I am asking honestly, because I am not a professional programmer, so there may be some very good reasons for not implementing this, apart the “we worked like this for 24 years, we don’t need to add this feature now”.
    In Unity, the FIRST and most important parameter of any object is if that object is actually active in any way, or just waiting to be activated.

  2. As I REALLY want this feature, can someone point out to which is the most stable and efficient way to implement it as described?
    Meaning like a simple checkbox in the Editor, that will ensure the immediate deactivation of each and every function of the actor when the game is launched.

  3. Possible idea: is it possible to “save” an actor in some kind of buffer or cache where nothing of it will be active?

1 Like

If you want to build from source, you could easily add a SetActive() function to Actor that toggles Ticking and recursively toggles off all components. You could set up a function called on editor changes that calls this based on toggling a bool prop on the actor.

You can also do it with a plugin, or with a helper library, as other people in this thread have pointed out.

If you want it to work “just like Unity” then the first option is probably the way to go. If you have issues with making changes to the base engine code, then you’ll have to roll it another way.

1 Like