-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to call C++ _process(), _ready() reliably #1022
Comments
@ozzr Suggested I test _notification to capture
|
It seems to me that this and issue#72034 are the same issues. |
I have meet simular problem when I call a C++ function at gdscript _ready/_process func. And that C++ function has a parameter which type is not Variant (Object* or Ref). Crash will happen. |
Has this issue been fixed in 4.0 and 4.1 (beta 2 right now)? |
I can still reproduce the issue in 4.1.1 |
I think that godotengine/godot#83583 may also resolve this too if you'd be able to test, as I suspect its the same issue (I ran in to it in the form of "when I have a node from GDExtension that has _process method, the C++ one is not called at all after I attach GDScript", which that linked pr resolved) |
[Copying misplaced comment from https://github.com/godot-rust/gdext/issues/111 ...] If you apply the following patch:
(which just prevents it from stopping processing on errors - a serious hack) and you register _process again...
which causes the engine to complain
and then you override in GDScript...
then it works as you have expected: engine calls script which calls the native class function. |
I'm beginning to think that this might be a documentation kind of error... it seems like what godot considers to be a virtual function The error from the engine complaining (above^) is actually coming from the built-in/generated node.hpp register_virtuals() function (where it tries to bind _process as virtual if the implementation of the most-derived class is not equivalent to the (dummy) implementation in Node.) By binding it myself in _bind_methods, I prevent godot-cpp from binding it as virtual (I didn't realize but those error messages were also causing early abort (return) in the ClassDB functions). Falling out of that, it seems like you're not supposed to be able to call parent class virtual functions; probably why it couldn't be "found" by godot as its expectation is that if it is "virtual" it doesn't exist in that class, i.e. "hasn't been defined" is more like "is not supposed to be defined" (hence why it worked when I disabled that error and did not let it get registered as virtual) |
No. |
Some part(s) of this issue may be fixed by PR godotengine/godot#83583 which will be included in Godot 4.2 |
Godot beta 16
@outobugi and I are building a GDExtension terrain plugin. I have a C++ class with _ready() and _process() that I want to run. However some cases work, some cases don't. I can't tell what the right path without testing every possibility because it's so inconsistent, and there's no clear way to have it work properly in all cases.
Legend:
T -
@tool
modeEd - Editor mode
Gm - Running in Game
C - C++
GD - GDScript
rd - _ready() in C++ or GDScript
pr - _process() in C++ or GDScript
Symbols: Blank = N/A | + = Yes | X = No and it's likely a problem | E = Error, and maybe a problem
extends MyNode
, my C++ plugin. Issue: C++ runs one function but not the other!!super._ready()
,super._process(delta)
. Issue: In game, the debugger broke in and complained that these functions do not exist.Adding C++ Bindings
By binding _ready() and _process() in C++ w/ bind_method, we get console errors:
ERROR: Method 'Terrain3D::_process()' already registered as non-virtual.
, and also for ready. This applies to all. Initially, it seems these tests are worthless, but that turns out to not be true.1-6. C++ doesn't work at all, and notably does not work if a script is not attached!
7. Here we see 7 works across the board.
Summary
In summary, if we want a plugin that runs C++ _ready() and _process() we either have to:
Neither of these are good options as it stands.
Presumably there are similar inconsistencies with _enter_tree() and others.
Is there a better way to bind _ready() and _process? I'm using this:
Similar to #562, but for Godot 4
The text was updated successfully, but these errors were encountered: