x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why is FTickableGameObject::Tick() being called in the editor?

Hi, I'm implementing the FTickableGameObject in one of my manager classes.

 UCLASS()
 class UGameFlowManager : public UObject, public FTickableGameObject
 {
     GENERATED_UCLASS_BODY()
     virtual ~UGameFlowManager();
     
 
 public:
     virtual void Tick(float DeltaTime) OVERRIDE;
     virtual bool IsTickable() const OVERRIDE;
     virtual TStatId GetStatId() const OVERRIDE;
 
 private:
 
     TimeObject* _timeObject;
 
 };

The base FTickableGameObject class defines the function:

     virtual bool IsTickableInEditor() const
     {
         return false;
     }

It returns false for being tickable in the editor but my tick function is still being called. Am I doing something wrong? How do I turn of the tick in the editor?

I also never create an instance of my class, I guess this done by the editor to give it some functionality. If someone could shed a little light on this that would be great.

Product Version: Not Selected
Tags:
more ▼

asked May 28 '14 at 09:55 AM in C++ Programming

avatar image

Muanh
76 7 11 132

avatar image Backov Aug 06 '14 at 11:48 AM

Just ran into this, an answer would be nice.

avatar image intoxicat3 Jun 22 '17 at 06:33 PM

I just run into this as well. Anyone can help?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

So, some investigation found the answer to this pretty quickly, but it seems like a bug to me. Probably "legacy" behaviour.

Overriding IsTickableInEditor() to return false will not work because of this bit of code, I believe:

 bool bTickIt = TickableObject->IsTickable() && 
 (
     (TickType != LEVELTICK_TimeOnly && !bIsPaused) ||
     (bIsPaused && TickableObject->IsTickableWhenPaused()) ||
     (GIsEditor && !IsPlayInEditor() && TickableObject->IsTickableInEditor())
 );
 

in LevelTick.cpp. As you can see that OR makes it behave strangely.

The solution I came up with:

 virtual bool IsTickable() const override { return (!GWorld->HasBegunPlay() && GIsEditor) ? false : true; }

If we're in the editor, and NOT playing, don't tick. Otherwise, tick.

more ▼

answered Aug 06 '14 at 12:02 PM

avatar image

Backov
289 22 131 50

avatar image Shadowriver Aug 07 '15 at 07:00 PM
 return (!GWorld->HasBegunPlay() && GIsEditor) ? false : true;

Can be replaced just with

 return GWorld->HasBegunPlay() && !GIsEditor;

&&, || and ! are Boolean operators and can be used anywhere as all math operators :)

avatar image Daverkex Apr 13 '16 at 11:28 PM

Still passed on 4.10 can confirm this bug Epic?

avatar image intoxicat3 Jun 22 '17 at 08:05 PM

4.16 - example solution is ticking in editor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I am seeing this as well, and even if there is no instantiated version of my TickableObject.

This implies it must be the CDO ticking (Class Default Object, which UE4 makes for each class so it knows default variable settings).

Using this should work to stop the CDO ticking even in 4.16:

 bool UMyTickableObject::IsTickable() const
 {
 // Tick only if we are both NOT a template and if we are specifically not in-editor-before-beginplay is called.
     return (!IsTemplate(RF_ClassDefaultObject)) && !(GIsEditor && !GWorld->HasBegunPlay()
 }

but note that I'm seeing IsTickable() called several times a frame on the CDO when I log it - this doesn't feel like everything is good on the engine side.

more ▼

answered Jun 27 '17 at 11:12 PM

avatar image

DaGaffer
137 3 6 8

avatar image Obelisk_Ali Jun 29 '17 at 04:29 PM

Hi!

I observed the same problem a few days ago in my project. Upon trying your code, it indeed stops the CDO from ticking, but in my case, even an instance doesn't tick anymore. I have instanciated the uobject in a custom GameInstance, if that makes any difference. I'm also in 4.16, and this is pretty puzzling.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question