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

Port 2D Skeleton demo to Godot 4.1 #976

Merged
merged 11 commits into from
Oct 25, 2023
Merged

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Oct 8, 2023

References #697.

Major changes:

  • Recreate tilemap so it will display correctly. New setup uses terrains and autotile mostly works when painting.
  • Change stretch, window, and camera settings to frame the world.
  • Copy 2d/platformer character controller code.
  • Use requests and correct ids with AnimationTree.
  • Rework parallax background. I'm not familiar with using this node, but I got it working. The world isn't large so the camera doesn't move much, but that's not what we're showing off in this demo.

Screenshot:
Screenshot of world

Showing character animation (captured before I got parallax background setup):
Video of character animation

@idbrii idbrii changed the title Port 2d Skeleton project to Godot 4.1 Port 2D Skeleton demo to Godot 4.1 Oct 8, 2023
@Calinou Calinou added the update label Oct 8, 2023
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Godot 4.1.2, it works as expected.

I get some warnings when opening the project in the editor though:

WARNING: No Bone2D children of node Chin. Cannot calculate bone length or angle reliably.
Using transform rotation for bone angle
     at: calculate_length_and_rotation (scene/2d/skeleton_2d.cpp:451)
WARNING: No Bone2D children of node RightHand. Cannot calculate bone length or angle reliably.
Using transform rotation for bone angle
     at: calculate_length_and_rotation (scene/2d/skeleton_2d.cpp:451)
WARNING: No Bone2D children of node LeftHand. Cannot calculate bone length or angle reliably.
Using transform rotation for bone angle
     at: calculate_length_and_rotation (scene/2d/skeleton_2d.cpp:451)
WARNING: No Bone2D children of node LeftFoot. Cannot calculate bone length or angle reliably.
Using transform rotation for bone angle
     at: calculate_length_and_rotation (scene/2d/skeleton_2d.cpp:451)
WARNING: No Bone2D children of node RightFoot. Cannot calculate bone length or angle reliably.
Using transform rotation for bone angle
     at: calculate_length_and_rotation (scene/2d/skeleton_2d.cpp:451)

Could these be resolved without affecting functionality?

@idbrii
Copy link
Contributor Author

idbrii commented Oct 20, 2023

I'll have a look at those warnings. I didn't try to fix them yet.

@idbrii
Copy link
Contributor Author

idbrii commented Oct 22, 2023

Fixed those warnings. Seems that you need to manually disable the auto calc option on leaf nodes.

Output and Debugger > Errors have no warnings or errors and it still looks right to me:

gd-skeleton.mp4

@idbrii
Copy link
Contributor Author

idbrii commented Oct 22, 2023

Updated the readme to "Renderer: Forward+" even though I didn't make that change because looks like that's now true and other demo updates are making the same change. I guess GLES2 was the default before and the new default is Forward+ so no change in config files is visible?

@Calinou
Copy link
Member

Calinou commented Oct 22, 2023

Updated the readme to "Renderer: Forward+" even though I didn't make that change because looks like that's now true and other demo updates are making the same change. I guess GLES2 was the default before and the new default is Forward+ so no change in config files is visible?

GLES3 is the default in 3.x, and Forward+ in 4.x.

That said, I suggest changing this demo to use Compatibility if it doesn't need features only available in Forward+. Remember to also do this for the .mobile override of the Rendering Method setting in the project settings dialog.

Auto changes from opening in v4.1.1.stable.official [bd6af8e0e]
Layout the nodes so you can see how the tree is setup.
Move camera from player to level so we can see the size it's going to
use.

Change application window to match level dimensions. Set stretch
settings to keep our aspect ratio since there's nothing else to display.

level.gd no longer does anything useful, so remove it.
Create a tileset from scratch. The old one seemed completely broken, so
this seems like an improvement. Now you can jump around the level.

Change the mountain positions in background. I don't understand how this
is supposed to work, but now they show up in the background of the
level.
Fix warning "AnimationTree: 'fall', Value Track:
'Sprite2D/Skeleton2D/Hip:position' must have at least one key to cache
for blending."
Fix character stutters when walking up ramps.

Instead of entirely unique code for this demo, copy the setup from 2d
platformer and strip out some of the fancy features: shooting and audio.
Also bring over the CharacterBody2D settings from the 2d platformer.

Doesn't feel great (long jumps don't always work, change direction isn't
satisfying), but better than before.
Fix "SCRIPT ERROR: Invalid set index 'parameters/state/state'
(on base: 'AnimationTree') with value of type 'int'"

Change:
parameters/state/current -> parameters/state/transition_request
parameters/land_hard/active -> parameters/land_hard/request etc
true -> AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE

Player now animates in idle, walk, fly, and fall. jump, land, and
land_hard fire. land doesn't look very good and jump doesn't look as
good as fly, but everything works.
Fix jump arm is stuck pointing out during jump.
Fix land glitches and looks like it plays twice.

Not necessary for land_hard, but seems like I should setup all the same?
Move camera back to player.
Shrink window and setup camera limits so the camera moves around in the
world.

Copy parallax setup from 2d/platformer -> skeleton and use the same name
for the scene. That wasn't enough, so fiddle with parallax until it
fills the bg and I can see some movement. There's not much because the
camera doesn't have much space to move.
Fix warnings "WARNING: No Bone2D children of node Chin. Cannot calculate
bone length or angle reliably. Using transform rotation for bone angle."

Those warnings were output for each Bone2D without any child Bone2D:
* Chin
* LeftFoot
* LeftHand
* RightFoot
* RightHand

Disabling the auto calculation seems to have filled in lengths and
bone_angles. Presumably these are the transform rotations that it would
use anyway.

Test
* run and jump around the world and animations look correct to me.
Godot 4 new default is Forward+, but we don't seem to require any
features from that, so switch to the most compatible choice instead.

Test
* win64 editor build. run and jump around and it looks the same as
  before.
@idbrii
Copy link
Contributor Author

idbrii commented Oct 24, 2023

Seems fine in GL Compatibility. All three modes are using GL Compatibility now and rebased on master.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on 4.2.beta3, I don't get any error messages anymore.

Thanks!

@Calinou Calinou merged commit 757cc42 into godotengine:master Oct 25, 2023
1 check passed
@idbrii idbrii deleted the skeleton-4 branch October 26, 2023 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants