PrimaryComponentTick.bCanEverTick appears to be working in the component constructor for me. When set to false, the “Is Component Tick Enabled” node will correctly return false when called from a blueprint using my custom component. To enable ticking for the component, first bCanEverTick needs to be set to true, then SetComponentTickEnabled(true) needs to be called. SetComponentTickEnabled() will check if bCanEverTick is true and, if so, will call SetTickFunctionEnabled(). This is why you have to update bCanEverTick prior to calling SetComponentTickEnabled().
You did not mention code in your component tick function. I was only using the blueprint node for quick verification, changing/updating bCanEverTick and calling SetComponentTickEnabled was done through code. Additionally, the comment explaining bCanEverTick in code states “If false, this tick function will never be registered and will never tick. Only settable in defaults.” This would imply that setting bCanEverTick to false wouldn’t prevent the component from ticking even if you changed this value during runtime.
Rather than setting bCanEverTick, if your goal is to have the component not tick when spawned have start ticking sometime after runtime, you can instead set PrimaryComponentTick.bStartWithTickEnabled = false; to prevent the component from starting with tick. You can then call SetComponentTickEnabled(true); to enable ticking afterward. This was tested with an AddOnScreenDebugMessage() in the TickComponent function that did not print when I started pie but did print after calling SetComponentTickEnabled.
I just tried making a project to reproduce the issue and I made another discovery. It’s actually the new compile feature in 4.15 that’s causing the problem.
When I made a new project, I created a component and used “PrimaryComponentTick.bStartWithTickEnabled = false” in the constructor. I went to the editor and pressed compile, and my debug message in the TickComponent was still firing. After closing the project and doing a git-clean, then rebuilding, the problem was gone. It seems like a bug that the new editor compile only works on some of the CPP class. Any thoughts on this?
After investigating further, when trying to activate/deactivate a component the most consistent method to do so is to set bAutoActivate in the constructor. With this variable set to 0 (false), the component doesn’t tick (regardless of PrimaryComponentTick settings). You can then call Activate(true); or Deactivate(); during runtime to start/stop the component tick.
,
Thank you for continuing to my posts. The issue is not resolved, so please don’t mark it as resolved. Here’s video evidence that there is a bug. I made fresh project and demonstrated the bug in less than 4 minutes. In summary, the component tick settings do not take hold unless the Unreal Editor is closed and re-opened. Hot reload is failing.
I have entered a report about the behavior of bCanEverTick inside component classes here: Unreal Engine Issues and Bug Tracker (UE-42944) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.