WickeyWare

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
spine3.6.png



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


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)
У вас нет необходимых прав для просмотра вложений в этом сообщении.
WickeyWare
  • Сообщения: 29

badlogic

That is a bug! I've filed an issue here and will follow up once I figured out what's going wrong. [lua] IK constraint not working as intended · #1353
Аватара пользователя
badlogic

Mario
  • Сообщения: 2076

badlogic

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.
Аватара пользователя
badlogic

Mario
  • Сообщения: 2076

WickeyWare

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
Screen Shot 2019-05-14 at 12.25.43 PM.png

vs not equipping the weapon
Screen Shot 2019-05-14 at 12.27.22 PM.png
У вас нет необходимых прав для просмотра вложений в этом сообщении.
WickeyWare
  • Сообщения: 29

badlogic

Cheers, I've re-opened the issue and am having another look.
Аватара пользователя
badlogic

Mario
  • Сообщения: 2076

badlogic

This is now fixed in the 3.7 and 3.8-beta branches. Thanks for reporting!
Аватара пользователя
badlogic

Mario
  • Сообщения: 2076

WickeyWare

Confirmed fixed. Thank you!
WickeyWare
  • Сообщения: 29


Вернуться в Bugs