Hello ! π
I have a question about the life cycle of nodes implemented in GDExtension (C++ in my case), in particular in the editor.
I just finished the tutorial with the GDExtension C++ example :
https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html#doc-gdextension-cpp-example
Just in case, you can find the C++ node implementation below :
#include "gdexample.h"
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
void GDExample::_bind_methods() {
}
GDExample::GDExample() {
// Initialize any variables here.
time_passed = 0.0;
}
GDExample::~GDExample() {
// Add your cleanup here.
}
void GDExample::_process(double delta) {
time_passed += delta;
Vector2 new_position = Vector2(10.0 + (10.0 * sin(time_passed * 2.0)), 10.0 + (10.0 * cos(time_passed * 1.5)));
set_position(new_position);
}
By the end of the tutorial, I was surprised to see my node floating around without having to run the game, in the editor 2D viewport.
In GDScript, to achieve the same thing, I would need to add the @tool
annotation.
Questions :
- Is it normal and expected, that the
_process
method of my GDExtension node gets executed in the editor ? (and not only in runtime ?) - If it is, can it be the source of unexpected side-effects in the editor ? (e.g. node properties being edited and overridden in the scene)
Have a nice day π