getter / return of a boolean correct if called within the class, incorrect if called from another class???

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mark C

Having had problems with getting the state of a boolean in another class (I’m using it to see if a body is set as “hiding” when it is returned from a RayCast2D, but other use cases will come up!), I’ve made the simplest possible code to act as a test-bed.

  1. “Level2” has a “Man” as a child node.
  2. “Man” calls it’s getter method in its _physics_process - this always reports the boolean correctly
  3. “Level2” calls Man’s getter method from with Level2’s _physics_process (I have also tried _process as seen below), no matter the value of the bool in Man, it returns “false”

note: I have no code within the program that would alter the bool value i.e. there is no “setter” or any other assignment operator.

Code snippets below - isReportedCorrectly is set to true: (I will provide entire code on request, but the rest is just the standard boilerplate that appears in all classes/scripts)


bool Man::get_isReportedCorrectly() {
    if (isReportedCorrectly) {
        Godot::print("is true");
    if (!isReportedCorrectly) {
        Godot::print("is false");
    return isReportedCorrectly;

Man _physics_process

void Man::_physics_process(float delta) {

Level2 _process

void Level2::_process(float delta) {


is false
is true
is false
is true

Expected Results

is true
is true
is true
is true

How is isReportedCorrectly defined in Man?
The _process function in Level2 will run before Man’s process functions, i’m thinking something is happening before Man’s process is called

LittleBigBug | 2020-02-27 19:26

Header file Man.hpp - declaration

#pragma once
#include <Godot.hpp>
#include <KinematicBody2D.hpp>

namespace godot {
   class Man : public KinematicBody2D {
      GODOT_CLASS(Man, KinematicBody2D);
      bool isReportedCorrectly;

and in implementation it’s only mentioned in _ready as below

void Man::_ready() {
   isReportedCorrectly = true;

Have you managed to get a simple bool to report correctly by the class calling the method itself, and also by calling it as a referenced class method from another class?

Mark C | 2020-02-28 11:25