godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.14k stars 21.19k forks source link

Skeleton2D IK targets the wrong node when running in multiplayer #86945

Closed chrisl8 closed 10 months ago

chrisl8 commented 10 months ago

Tested versions

v4.2.1.stable.official [b09f793f5]

System information

Godot v4.2.1.stable - Windows 10.0.22621 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3080 Ti (NVIDIA; 31.0.15.4633) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Issue description

I expect when setting up a Skeleton2D with a Modification Stack with a Target Nodepath that each instanciated instance of that Skeleton will follow the Target Nodepath that is local to that scene.

However, instead EVERY instance of the spawned skeleton follows the SAME Target Nodepath.

We worked on this for about 48 hours but were unable to find any way around this.

Steps to reproduce

You must set up your Debug->Run Multiple Instances to at least 3.

One of the windows opened will be the server, and will basically look blank, just ignore it.

The other two will focus on yoru characters.

You can use WASD to move the character around if you need to prove which window you are controlling and/or which character is native to that window.

Move the mouse around in front of both windows and you will see that BOTH IK skeletons follow the SAME pointer. They are both following ONE of the two (or 3) Player/Left Hand Target nodes, rather than each following the Player/Left Hand Target node within their respective player.

https://github.com/godotengine/godot/assets/6188278/b7a03272-d56f-42b9-8426-34b9266435b4

Minimal reproduction project (MRP)

https://github.com/chrisl8/godot-ik-broken-multiplayer

or

godot-ik-broken-multiplayer.zip

kleonc commented 10 months ago

Looks like this has the same cause as #73888, see https://github.com/godotengine/godot/issues/73888#issuecomment-1646554361 for details.

I couldn't open player.tscn in the MRP (it said it's corrupted :thinking:) but manually adding resource_local_to_scene = true within the player.tscn to its only SkeletonModificationStack2D so it's like:

...
[sub_resource type="SkeletonModificationStack2D" id="SkeletonModificationStack2D_tbk5s"]
resource_local_to_scene = true
...

made only one of the skeletons follow the pointer. So the same workaround seems to work in here too.


(Still not sure what's meant to be done about it. And whether this should be marked as duplicate or what. :upside_down_face:)

chrisl8 commented 10 months ago

@kleonc Thank you. I hadn't realized that the above issue is the same problem.

Give me a day or two to check into this and if it does fix my issue then I'll close this as a duplicate.

kleonc commented 10 months ago

Reopening the project should make it open. Not sure why Godot claims it is corrupt though.

@chrisl8 Reopening indeed made the error go away. :upside_down_face:

Does setting it to local actually make both players work or just disable one of them entirely?

Oh, it rather disables one. But enabling resource_local_to_scene for both SkeletonModificationStack2D and SkeletonModification2DTwoBoneIK does the thing for me, works even for 4 windows / 3 players. Godot_v4 2 1-stable_win64_OZCvds6gCd

chrisl8 commented 10 months ago

Thank you again so much for the further explanation!

And sorry for confusing your reply by editing mine.

chrisl8 commented 10 months ago

@kleonc Thank you so much again for taking time to respond to my issue report and for explaining the solution so clearly. Indeed I had found, actually days ago, the "Local to Scene" checkbox, but I did not find the second one, so your screenshot was the final solution for my complete understanding.

I also found the script in this comment to be ideal, as it was easy to add that to each Skeleton in the project and then my other team mate doesn't have to worry about checking the right boxes.

I will close this as a duplicate of Issue #73888 and will subscribe to that issue to watch for solutions to test while using the workaround that you and others provided.