AlmasB / FXGL

Java / JavaFX / Kotlin Game Library (Engine)
http://almasb.github.io/FXGL/
MIT License
4.45k stars 555 forks source link

How can I add a click event to a 3d entity when I set settings.set3D(true) #1375

Open cnless opened 5 months ago

cnless commented 5 months ago

I have tried using entity.getViewComponent().addOnClickHandler and entityBuilder().onClick, but it seems that these methods do not work.

AlmasB commented 5 months ago

Hi, that's a good point. The 3d counterpart will probably need a separate implementation.

For now, I've found this: https://stackoverflow.com/questions/28863312/javafx-3d-graphics-mouse-click-position-on-3d-object

See if it works for your use case. If yes, I can use the proposed solution as a basis.

cnless commented 5 months ago

Hi, that's a good point. The 3d counterpart will probably need a separate implementation.

For now, I've found this: https://stackoverflow.com/questions/28863312/javafx-3d-graphics-mouse-click-position-on-3d-object

See if it works for your use case. If yes, I can use the proposed solution as a basis.

I have found the cause of the problem.The entity seems to be obscured by my UINode.