ultrafop

  • 24일 전
  • 2019년 9월 16일에 가입함

    @ultrafop Thanks for the additional details. If you're using a single script to query the location in LateUpdate, then it should not be an issue with script execution order of LateUpdate in relation to other scripts, if there is only one script involved.

    To diagnose the issue better: Are the bone locations behind just the first frame after enabling your skeleton GameObject? Or is it behind a frame all the time during playback? You could quickly test this by assigning the queried projectile spawn location every frame to a GameObject's Transform position.

    My current best guess would be that the script that enables the skeleton GameObject is late, so that the enable-script's Update method is called after SkeletonAnimation.Update, enabling the skeleton but the Update is occurring next frame. Thus you could have a try calling SkeletonAnimation.Update(0) after enabling your skeleton GameObject, and after setting the desired animation.

    • ultrafop님이 이에 답장했습니다.

      @ultrafop For general info on what updates when in the spine-unity runtime, see:
      https://esotericsoftware.com/spine-unity-main-components#Script-Execution-Order

      ultrafop If I have it toggled off and then set it to toggle on (think Megaman starting a stage), the projectile seems to come out at the last known position of the arm I'm aiming, even though the animation is updating.

      I'm not sure how you determine the spawning position. If you use the BoneFollower component, that might not have been updated this frame between setting and applying the animation and spawning the projectile.

      BoneFollower updates the position in LateUpdate, so you might want to make sure your component which determines the location executes after the BoneFollower component, or call boneFollower.LateUpdate() manually before querying the position.

      Another potential source of error might be from where (from which update method) you are enabling the GameObject. This might be out of order regarding the other components as well.

      ultrafop I moved my projectile script (what fires objects from my pool) from the parent into the child/animation object, after my animation script, but the problem persists.

      Note that it makes no difference in regards to script execution order if you move a component from a parent to a child GameObject. Also it makes no difference whether your component is shown above or below other components at the same GameObject. See the Unity documentation:

      You cannot specify the order in which an event function is called for different instances of the same MonoBehaviour subclass. For example, the Update function of one MonoBehaviour might be called before or after the Update function for the same MonoBehaviour on another GameObject — including its own parent or child GameObjects.