paulp

  • 3 févr.
  • Inscrit 12 juin 2023
  • paulp

    As @SilverStraw mentioned in their answer, the controlBones array allows you to show a draggable controller for the bone.

    If you prefer, you can also make your bone react to cursor movement without dragging. You'll just need to go a little deeper. Here's what you can do:

    • In the success callback:
      • Set up an input listener that stores the mouse position in the Spine world coordinates
      • Store the target bone
    • In the update callback (which is executed right before the skeleton is drawn):
      • Transform the mouse position locally to the target bone
      • Set the new target bone position

    Here's an example using Spineboy with the aim animation.

    const mouseWorldPosition = new spine.Vector3();
    const targetModifiedPosition = new spine.Vector3();
    let targetBone;
    
    var jsControlledPlayer = new spine.SpinePlayer("spineboy-raptor", {
    	skeleton: "assets/spineboy-pro.skel",
    	atlas: "assets/spineboy-pma.atlas",
    	animation: "aim",
    	showControls: false,
    	premultipliedAlpha: true,
    	success: ({ canvas, sceneRenderer, skeleton }) => {
    		// setup listener
    		new spine.Input(canvas).addListener({
    			moved: (x, y) => {
    				mouseWorldPosition.set(x, y, 0)
    				sceneRenderer.camera.screenToWorld(mouseWorldPosition, canvas.clientWidth, canvas.clientHeight);
    			},
    		});
    
    		// save target bone
    		targetBone = skeleton.findBone("crosshair");
    	},
    	update: () => {
    		// store the position in another vector to avoid infinite transformation of mouse position
    		targetModifiedPosition.set(mouseWorldPosition.x, mouseWorldPosition.y)
    
    		// transform the mouse world position, to the bone local
    		targetBone.parent.worldToLocal(targetModifiedPosition);
    
    		// set the target bone position
    		targetBone.x = targetModifiedPosition.x;
    		targetBone.y = targetModifiedPosition.y;
    	}
    });
  • paulp
    It looks like you have to define an array of bones names to "controlBones" configuration setting.

    new spine.SpinePlayer("player-container", {
        ...
        controlBones: [ "control_bone_a", ... ] ,
        ....
    } );

    EsotericSoftware/spine-runtimesblob/4.2/spine-ts/spine-player/src/Player.ts#L327
    EsotericSoftware/spine-runtimesblob/4.2/spine-ts/spine-player/src/Player.ts#L505

  • @paulp One more update, could you please test this version:

    spine-skeletonlit-urp-2d.txt
    7kB
    • @paulp Bad to hear, thanks for the feedback.

      To be sure we're on the same page: Are you testing with the exact same reproduction project that you sent us last, and play this in the Unity Editor play mode with active target being Playstation 4 or Playstation 5?

      I'm asking to be sure you're not perhaps testing a more complex scene where other shaders are used, like additive or multiply shaders instead of the URP/2D/Spine/Skeleton Lit shader.

      • @paulp Could you please try this second modified version of the shader and let us know the results:

        spine-skeletonlit-urp-2d.txt
        7kB
        • @paulp Unfortunately so far we were out of luck reproducing the issue on our end again. Nevertheless, below you can find a slightly modified version of the shader before I'm leaving the office for today, to hopefully speed up the process a little bit:

          spine-skeletonlit-urp-2d.txt
          7kB

          Tomorrow I will hopefully find more time, apologies for the inconvenience!

          • @paulp That's unfortunate indeed, thanks for the feedback. We will continue our investigations.

          • @happyjiahan Note that there is also an example scene provided which shows how to do this:
            Spine Examples/Other Examples/Instantiate from Script.
            The GameObjects 3 RuntimeLoadFromExports and 4 Runtime BlendModes from Exports show how you can instantiate skeletons from just the exported files.

            It's always worth having a look at the example scenes, as many common scenarios are demonstrated there already.

            • @paulp Thanks for the info! This seems to be confirming that the issue is due to special handling of undefined behaviour. We will continue our investigations.

            • @paulp Unfortunately for strange reasons, while Misaki could immediately reproduce the issue, I could not yet reproduce it on my machine using either Unity 2022.3.18, 2022.3.35 nor the exact submitted version 2022.3.30 with Android being set as the active build target. I will get back to you as soon as I can reproduce the issue as well (hopefully tomorrow).

            • paulp Thank you for sending us the minimal Unity project! I have indeed confirmed that I can reproduce the problem on a Windows PC. (I was able to reproduce this issue on both iOS and Android for the platform.)
              It appears that the cause is in your Universal Render Pipeline Asset settings: in the Quality section, the HDR check is turned on, but if you uncheck this, the skeletons will be displayed correctly. For more details, please wait for a response from Harald.

            • We'll release 4.1.23 with a fix for this today. Sorry for the trouble!