gdquest-demos / godot-2d-tactical-rpg-movement

Grid-based movement for a Tactical RPG
Other
127 stars 22 forks source link

Update to Godot 4.0 #3

Closed 3d12 closed 1 year ago

3d12 commented 1 year ago

Lots of little changes. Here are some highlights:

Please check if the PR fulfills these requirements:

Related issue (if applicable): #

What kind of change does this PR introduce? Updates the 'finished' version of the project to GDScript that's compatible with Godot v4.0

Does this PR introduce a breaking change? Yes, this version of the project will no longer be able to be opened in prior versions of Godot (< 4.0)

New feature or change

What is the current behavior?

What is the new behavior?

Other information

NathanLovato commented 1 year ago

Thank you very much for taking the time to port this code to Godot 4.

Because we have this published tutorial for Godot 3 on our website, I think we shouldn't override the main branch of this repository.

At the same time I don't think we want to adapt this tutorial series as is in Godot 4. It would likely make more sense to take this further and make a little tactical RPG demo for the community (with combat actions, player and enemy turns, AI...).

I'll check with my teammates. We have a busy todo right now but we'll do our best to get back to do within a reasonable timeframe.

3d12 commented 1 year ago

It's no problem, I was following that superb Godot 3 tutorial and made updates as I went, in order to to get stuff to run. Then I saw afterwards that this was requested in issue #2 😄

Feel free to use any of this code in that future demo/tutorial, and I look forward to seeing it!

Until then, I hope this code is helpful for anyone else in my situation. If it would be more helpful instead to place into a different folder (godot4/) instead of overwriting the main (godot/) I could do that, or if you'd rather close this PR I understand.

Thanks again for the fantastic content! You and your team are very appreciated! ❤️

NathanLovato commented 1 year ago

I just found time to test this. Moving the files to a godot4/ directory and keeping the original godot/ directory would definitely be great.

While testing I noticed two issues:

  1. Characters rotate along the path when moving.

image

  1. It's minor but resetting the path progress causes an error in the debugger. It'd be nice to address if possible, though it's no big deal.

image

If you have the time, could you make the changes? If not, please let us know and we will take care of this.

3d12 commented 1 year ago

This is done, thanks for taking the time to test and offer suggestions. :slightly_smiling_face:

I fixed the rotation in the _ready() function of Unit.gd -- this could also be ticked in the editor, if preferred.

The Zero Length Interval error has a slightly weirder fix... https://github.com/3d12/godot-2d-tactical-rpg-movement/blob/4760599d54f9152d538274e901a97c8fb2165e26/godot4/Units/Unit.gd#L80-L81

I chased down where in the engine this is happening, it seems to be based on the offset being compared to FLT_EPSILON, a cpp constant. The smallest value I could set it to on my machine without triggering this error is 0.00000000000000001. It appears this offset value is being "snapped" to the nearest baked point in the Curve and as long as it can snap to the 2nd value instead of the first (which in my curve is also (0,0), using Curve.get_baked_points() for debug) it avoid this Zero Length Interval error. https://github.com/godotengine/godot/blob/92bee43adba8d2401ef40e2480e53087bcb1eaf1/scene/resources/curve.cpp#L915-L918

NathanLovato commented 1 year ago

Thanks much for the work and help!