• Bugs
  • Issue with IK use in Corona Runtime using v 3.7

When using Gunman Asset Pack aiming is done by rotating an IK called AimPivot. In Spine 3.6 this worked. In 3.7, it no longer works at all.

I will show pictures and explain as clearly as possible.

This is how it works in 3.6. The entire body is rotated with the AimPivot

In 3.7 nothing rotates except the weapon itself. The arms stay fixed.

The issue lies in Animation.lua or the AnimationState.lua files as if I revert those two alone the issue is resolved.

Each tick of the game this occurs

local currentTime = system.getTimer() / 1000
local delta = currentTime - lastTime
lastTime = currentTime
animationState:update(delta)
animationState:apply(skeleton)
skeleton:updateWorldTransform()

aiming the weapon simply does this

obj.aim = function(val)
    if (aimPivotBone == nil) then
        aimPivotBone = skeleton:findBone("AimPivot")
    end
    aimPivotBone.rotation = val
end

and equipping a weapon

animationState:setAnimationByName(1, "weapon.setupAnim", false)
animationState:setAnimationByName(2, "weapon.idleAnim", true, 0)
Related Discussions
...
  • Изменено

I've looked into this, using the following test code and the original Gunman asset:

require("mobdebug").start()

local spine = require "spine-corona.spine"

function loadSkeleton(atlasFile, jsonFile, x, y, scale, animation, skin)
   local imageLoader = function (path)
      local paint = { type = "image", filename = "data/" .. path }
      return paint
   end
   local atlas = spine.TextureAtlas.new(spine.utils.readFile("data/" .. atlasFile), imageLoader)
   local json = spine.SkeletonJson.new(spine.AtlasAttachmentLoader.new(atlas))
   json.scale = scale
   local skeletonData = json:readSkeletonDataFile("data/" .. jsonFile)
   
local skeleton = spine.Skeleton.new(skeletonData) skeleton.scaleY = -1 skeleton.group.x = x skeleton.group.y = y if skin then skeleton:setSkin(skin) end local animationStateData = spine.AnimationStateData.new(skeletonData) animationStateData.defaultMix = 0.5 local animationState = spine.AnimationState.new(animationStateData) return { skeleton = skeleton, state = animationState } end local lastTime = 0 local result = loadSkeleton("Gunman.atlas", "Gunman.json", 240, 300, 0.4, "Run") local skeleton = result.skeleton local state = result.state state:setAnimationByName(0, "Run", true) state:setAnimationByName(1, "Aim_Sniper", true) local aimBone = skeleton:findBone("AimPivot") display.setDefault("background", 0.2, 0.2, 0.2, 1) Runtime:addEventListener("enterFrame", function (event) local currentTime = event.time / 1000 local delta = currentTime - lastTime lastTime = currentTime aimBone.rotation = 45; state:update(delta) state:apply(skeleton) skeleton:updateWorldTransform() end)

Which gives the following expected result using the 3.7 runtimes:

https://marioslab.io/uploads/screenshots/2yigZ6lmTr.png

Please modify the above code to reproduce the issue.

Thanks for the quick response!

Unfortunately there's still something there. Just add a single line of code to your example to equip the weapon and it no longer rotates.

state:setAnimationByName(0, "Idle", true)
state:setAnimationByName(1, "Setup_Sniper", false) 
state:setAnimationByName(2, "Aim_Sniper", true) 

See here

vs not equipping the weapon

Cheers, I've re-opened the issue and am having another look.

This is now fixed in the 3.7 and 3.8-beta branches. Thanks for reporting!

Confirmed fixed. Thank you!