jkvastad / Godot-4-Card-Hand-Tutorial

Tutorial project for a hand of cards. Showcases object picking, animation with tweens, raycasting asynchronously queued from events, and more! Project for Godot 4, code written in C#.
MIT License
6 stars 0 forks source link

Adding Camera2D to Project Breaks Drag-and-Drop Functionality #1

Open T3ster12 opened 7 months ago

T3ster12 commented 7 months ago

Love this project, it has helped me immensely! I'd like to add a camera2D to this scene and have the cards on the HUD in the foreground while moving the camera across a scene in the background. But any camera2D that isn't fixed to top left breaks the drag-and-drop functionality. I believe this because the card tracking/offset/positioning is based on global positioning in CardIsClicked() when I need more relative positioning to the HUD.

Is there a straightforward way to modify this code to work with a camera2D that isn't fixed to the top left? Thanks for any insight and thanks again for this project!

jkvastad commented 7 months ago

Glad you like the project! You are probably spot on with the bug/missing feature, I did not test it with a Camera2D. In fact this is one of my earliest Godot projects because I found nothing on the subject so it is very much a "blind leading the blind" kind of deal :P

I mean to get back to these later on but I'm a bit swamped with work right now. I'll add Camera2D compatibility to the backlog. If you want a go at it I would look at all the calls to a global position and fiddle around with making them relative to a Camera2D.

While on the subject, and looking back after a few months of Godot, I think a lot of the problems stem from whether to use Godots InputEvents versus input polling. Currently I got a multiplayer card game with both 2D and 3D objects working (think Hellcard), and I got the whole "cards on HUD, movement in the back" going. I decided to go with only input polling because then I can make custom input interpretations per game state and handle complex things like "2d card in front of clickable 3D object behind main menu Control node".

Hope this helps, if only marginally. Good luck!

T3ster12 commented 7 months ago

It certainly helps! I'll give it my best and post the solution if I find one for anyone else looking to adapt this code/project.

Your game sounds very fun! Hope to see it out in the wild when it's done :)

Thanks again!