-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Attaching GDscript script to Rust class stops physics_process
from running
#111
Comments
Do you know if this is something that Godot generally supports? I found issue godotengine/godot#72034, but that talks about accessibility and not that the method themselves stop working. |
it appears related to godotengine/godot-cpp#1022 |
Thanks! There's probably not much that can be done on godot-rust side; I marked it as upstream for now. |
physics_process
from running
Ran into this as well. As mentioned in the linked issue, it seems like overriding E.g. for a fn init(base: Base<Node>) {
// Ensure we get Process notifications, defaults to false.
base.set_process(true);
}
fn on_notification(&mut self, notification: NodeNotification) {
match notification {
NodeNotification::Process => {
let delta = self.base.get_process_delta_time();
// ...
}
_ => {}
}
} |
This PR (which has just landed on 4.2 beta) has partially fixed this issue: godotengine/godot#83583 Now, the mere act of attaching a script to your gdext class will not suddenly make all overridden virtual methods (including However, if you explicitly override one of the virtual methods overridden by the extension, such as if you override |
Thanks for following this up and testing!
I think that's a rather rare use case though. Also, the attached GDScript is technically not a subclass of the GDExtension class. So I'll close this, but we could document that limitation. |
FYI I did dig a bit because I was curious, and I'm quite sure this is not supposed to work, however.... 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. (edit: sorry, I forget this is not a C++ repo - however it likely would work similarly.) |
@anrp Thanks a lot for looking deeper into this! Could you post this in godotengine/godot-cpp#1022? |
Well, I'd expect it to be very rare when developing GDExtension for one's own games, that's correct. But it might not be that rare when writing a GDExtension as a library for others to use. I guess it'd still be better to use
Hmm, maybe? I don't know much of the inner Godot architecture here, so I'll take your word for it. 🙂 Still, I guess it could be interesting to have
Sounds good to me! |
Given this code:
When running a project containing a
Mini
node, it printstest
repeatedly to the console as expected. However if you attach a script to the node, it will no longer print anything.The text was updated successfully, but these errors were encountered: