Skip to content
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

GDExtension overide StaticBody3D's virtual _mouse_enter(),but it does'nt work ,if overide StaticBody3D's virtual _input_event,it will work #1325

Closed
MAXFROMCODE opened this issue Dec 2, 2023 · 7 comments · Fixed by godotengine/godot#85870
Labels
bug This has been identified as a bug
Milestone

Comments

@MAXFROMCODE
Copy link

Godot version

4.2 stable

godot-cpp version

4.2

System information

win11

Issue description

f6e7f8f06af74f5312d36ed4925b655

i create a GDscript _mouse_enter() extend My new Class it work

Steps to reproduce

create a new Class public extend StaticBody3D,override <virtual void _mouse_exit()override> it doesn't work

Minimal reproduction project

N/A

@MAXFROMCODE
Copy link
Author

anyone what happend,please tell me ,I really want know why

@MAXFROMCODE
Copy link
Author

1701504220208

@MAXFROMCODE
Copy link
Author

_mouse_enter use UtilityFunctions::print("enter_mouse"); same bug

@dsnopek
Copy link
Collaborator

dsnopek commented Dec 6, 2023

Thanks for the report!

This looks like a bug in Godot - there's this code in CollisionObject3D:

void CollisionObject3D::_mouse_enter() {
	if (get_script_instance()) {
		get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
	}
	emit_signal(SceneStringNames::get_singleton()->mouse_entered);
}

void CollisionObject3D::_mouse_exit() {
	if (get_script_instance()) {
		get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
	}
	emit_signal(SceneStringNames::get_singleton()->mouse_exited);
}

It should be using GDVIRTUAL_CALL() rather than checking if get_script_instance() is truthy. I'll make a PR to Godot.

@dsnopek
Copy link
Collaborator

dsnopek commented Dec 6, 2023

I just posted PR godotengine/godot#85870 which should fix this!

@dsnopek
Copy link
Collaborator

dsnopek commented Dec 6, 2023

As an interim fix (before the PR is merged), you could connect to the mouse_entered and mouse_exited signals, rather than overriding the virtual methods

@AdSkipper1337
Copy link

Hello, I wanted to try the new GDExtension hot reloading and was playing arround with it when I got stuck with trying to have Area2D react to mouse events from GDExtension. I thought I was doing somehting wrong but turns out that was a genuine bug, and it is exactly the same error as here except for a slightly different case.
I already fixed it and made a PR godotengine/godot#86908
Its essentially exactly the same fix, except for it also has the functions _mouse_shape_enter and _mouse_shape_exit which have the exact same behavior.

Maybe this issue should be generalized to cover both cases since they are so similar?

Best

@akien-mga akien-mga added this to the 4.3 milestone Jan 8, 2024
@akien-mga akien-mga added the bug This has been identified as a bug label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants