You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my testing, it's printing out a valid pointer for all three cases!
I suspect there's another bug somewhere that affects certain ways of creating Godot objects, which was simply exposed by the change in PR #1037. So, we'll really need to see how your nodes are created in order to track down where the problem is.
@dsnopek
Sorry, I don't use SCons for my projects. But to reproduce a case, in a stock demo project, in test/src/example.cpp
append this code to void Example::_notification(int p_what) (after line 52)
if (p_what == NOTIFICATION_READY) {
auto just_node = get_node_or_null("Label");
auto label_node = get_node<Label>("Label");
auto cast_node = cast_to<Label>(just_node);
UtilityFunctions::print("NOTIFICATION_READY, just_node: ", just_node, " label_node: ", label_node, " cast_node: ", cast_node);
}
Object* oub = Object::cast_to<Object>((Object*)selected_array[x]); //success
Node* noub = Node::cast_to<Node>((Object*)selected_array[x]); //failure
Node* noub2 = Node::cast_to<Node>(selected_array[x]); //failure
//- then ---------------------------------------------------------------------------------
Node3D* nub = (Node3D*)(oub); //success
Node3D* nub2 = Node3D::cast_to<Node3D>(oub); //failure
//-- and to test if cast_to is working at all --------------------------------------------
Node* tub = nub->find_child("UnitBase"); //success
Node3D* ub = Object::cast_to<Node3D>(tub); //success
I do have a set of PR's that fix these regressions without reverting (since reverting will add some other bugs back :-)), but the changes are too big with 4.0's imminent release.
In any case, thanks for the extra info on how to reproduce, but this issue should be fixed very soon once the revert PR is merged. :-)
Activity
Withaust commentedon Feb 15, 2023
Also broken by #1037
dsnopek commentedon Feb 15, 2023
Can you share a minimal reproduction project?
I attempted to reproduce the issue, but was unable to - here's my project: object-cast-to-test.zip
The core of my project is a
GuiNodeclass that looks like this:In the game (in the
game/directory), there's a simple GDScript that does:In my testing, it's printing out a valid pointer for all three cases!
I suspect there's another bug somewhere that affects certain ways of creating Godot objects, which was simply exposed by the change in PR #1037. So, we'll really need to see how your nodes are created in order to track down where the problem is.
sash-rc commentedon Feb 15, 2023
@dsnopek
Sorry, I don't use SCons for my projects. But to reproduce a case, in a stock demo project, in
test/src/example.cppappend this code to
void Example::_notification(int p_what)(after line 52)It prints
Built with "editor" target, if this matters.
dsnopek commentedon Feb 16, 2023
@sash-rc In your example, how is the "Label" node created?
sash-rc commentedon Feb 16, 2023
@dsnopek
It's a part of demo scene, a child of Example node. Stored in
test/demo/main.tscndsnopek commentedon Feb 16, 2023
Oh, ok, you're using the demo project in this repo! Sorry, I didn't pick up on that from your original comment. Thanks!
codecat commentedon Feb 17, 2023
This caused some issues in TBLoader as well: codecat/godot-tbloader#68 and codecat/godot-tbloader#69
RonYanDaik commentedon Feb 19, 2023
on windows fails to cast.
dsnopek commentedon Feb 19, 2023
FYI, the change that is causing these issues is going to be reverted (Remi approved it but hasn't gotten around to merging it yet):
#1046
I do have a set of PR's that fix these regressions without reverting (since reverting will add some other bugs back :-)), but the changes are too big with 4.0's imminent release.
In any case, thanks for the extra info on how to reproduce, but this issue should be fixed very soon once the revert PR is merged. :-)