Hi there, I’m both new to Unreal Engine as well as C++ (mostly, let’s just go with new).
Coming from a Unity background, I am wondering if there is a way to disable an actor (rendering, physics, tick, etc.) and it’s components/children in a simply manner to be enabled again at a later stage. Unity, for example, has gameObject.SetActive(bool), is there an equivalent function or would I have to work around it?
‘bActive’ is the bool. You should disable tick on this actor while you deactivated it (like ‘SetComponentTickEnabled(false);’). I’m not 100% sure, but i think there is a toggle-function for all this (like the ‘ToggleVisibility()’-function).
When you have another question, let us know it!
Sincerely
EDIT: i’m also pretty new to UE4 (and come from Unity like you) so i don’t give a assurance for my answer. ^^
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?
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?
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.
“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 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.
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.
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:
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.
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