• Runtimes
  • Spine and LUA (Love2D)

  • Изменено
Related Discussions
...

So I am using Love2D as my engine with the spine runtime but I have no idea and I cannot seem to find any information on how to use the bounding box for collision checking in the engine itself?

Any Ideas? :x :x :x :x

Do you want to use Spine bounding boxes for collisions between themselves (e.g skeleton vs skeleton), or use them with love2d's physics engine or the HC module (https://love2d.org/wiki/HC)?

I want to use the HC module but I can't seem to get my game to detect the bounding boxes. Thank you for your time

Oki, here's a high level view of what to do

  1. Add bounding box attachments to your skeleton(s) in the editor
  2. In your code, you can get the current bounding box states like this


---

 you can create the bounds once and reuse them
local bounds = spine.SkeletonBounds.new();



---

 then every frame, update your skeleton, then update the bounds
animationState:update();
animationState.apply(skeleton);
skeleton:updateWorldTransform();
bounds:update(skeleton, true);



---

 Create HC polygons from the bounding box attachments
for i, bounds in ipairs(bounds.polygons) do
   
--- bounds represents the bounding box attachment vertices as (x1, y1, x2, y2, ...) coordinate pairs
--- in the skeleton's coordinate system. You can plug that into the HC polygon end

Now, doing this every frame might be costly depending on how HC implements the construction of HC PolygonShape

6 дней спустя

Thank you for the help, my other question would be how to mix the animations setanimation makes it look very static and addanimation makes it wait for the whole animation to be over and does not mix the animations at all.

Thank you for your help in advance.

Nate написал

Use a mix duration when you change animations:
Applying Animations - Spine Runtimes Guide: Mix times
You can preview mixing in the Preview in 3.6+.

I just did and in the preview it looks perfect, when I am using it in Love2D im using

playerSkeleton.state:setAnimationByName(0, "walk", true, 0)

this seems to just snap to the next animation and when i use

playerSkeleton.state:addAnimationByName(0, "walk", true, 0)

it waits for the prior animation to finish before snapping to the next one



EDIT: The Mix value is being set but is not being applied to the animation themselves.

I verified that they were being set using the getMix Function


EDIT 2:
I think it may be that my animations themselves are not setup correctly is there any setup i need to do on the animations themselves to allow mixing?

Hmm, it could be a spine-lua bug. badlogic can check it out as soon as he can (he's probably recovering from New Year's Eve :drunk🙂. You don't have to do anything for mixing other than specify the mix duration.

Note AnimationState setAnimationByName takes only 3 arguments. AnimationState addAnimationByName takes 4.

Is love.keypressed called every frame? If so, you don't want to set the new animation every frame.

You can try:

local entry = playerSkeleton.state:setAnimationByName(0, "walk", true)
print(entry.mixDuration)

If you don't see the right mix duration, something is bugged with how it gets set or configured. You can also try:

local entry = playerSkeleton.state:setAnimationByName(0, "walk", true)
entry.mixDuration = 0.25
Nate написал

Hmm, it could be a spine-lua bug. badlogic can check it out as soon as he can (he's probably recovering from New Year's Eve :drunk🙂. You don't have to do anything for mixing other than specify the mix duration.

Note AnimationState setAnimationByName takes only 3 arguments. AnimationState addAnimationByName takes 4.

Is love.keypressed called every frame? If so, you don't want to set the new animation every frame.

You can try:

local entry = playerSkeleton.state:setAnimationByName(0, "walk", true)
print(entry.mixDuration)

If you don't see the right mix duration, something is bugged with how it gets set or configured. You can also try:

local entry = playerSkeleton.state:setAnimationByName(0, "walk", true)
entry.mixDuration = 0.25

Setting it with entry.mixDuration fixed my issue when i printed the mix duration it printed out 0 setting it through entry.mixDuration fixed my problem. One last thing is it possible to use entry whenever I want to use that animation?

and Keypressed is called once when the button is clicked

Hmm, we'll look into why the mix duration wasn't retrieved by AnimationStateData correctly.

The TrackEntry represents the queued or current animation for the AnimationState. It can't be reused for playing the animation again later, but you can add or set the animation again and the AnimationState will give another track entry.

Hm, I checked that the mix data in AnimationStateData is applied properly. Could you send me a reproduction case (code + assets) that shows the problem you have?