defold / defold

Defold is a completely free to use game engine for development of desktop, mobile and web games.
https://www.defold.com
Other
3.9k stars 279 forks source link

Add optional offset argument to go and gui animate #8650

Open redoak opened 3 months ago

redoak commented 3 months ago

Is your feature request related to a problem? Please describe (REQUIRED): Property animations cannot be created with an offset to start playback from a point other than the beginning. Spine, Rive, model and flipbook all support offset. Its lack prevents useful things such as:

Describe the solution you'd like (REQUIRED): Add an optional offset argument to go.animate and gui.animate.

Describe alternatives you've considered (REQUIRED): Tweak the simulation or game design to avoid any glaring issues; hide any issues by having a brief fade-in transition; control properties manually in update.

Additional context (OPTIONAL): Related to feature request #5795 for pause and resume animation support.

AGulev commented 3 months ago

related, I think https://github.com/defold/defold/issues/3246

redoak commented 3 months ago

related, I think #3246

That's perfect. I was going to suggest a new API signature with a parameter list like other animation functions, with an options table and whatnot — but didn't want to be the guy who casually suggest you do extra work. :)

jcbk101 commented 3 months ago

I hate to pile on in THIS post, but I am dealing with gui.animate() / go.animate() this very moment and something I am trying to do is requiring 'hacking' and chaining.

In #3246 , tween.properties would rock if I could define a wrap around value that is other than an object's initial starting value.

For example:

-- Here, position.x is set to 0
gui.set_position(node, vmath.vector3(0, 0, 0))
-- In options / properties "from" becomes the new "position.x" starting point once "to" is reached
gui.animate( node, "position.x", to, gui.EASING_LINEAR, 1, 0, nil, gui.PLAYBACK_LOOP_FORWARD, { from = -10 } )

My initial thought was to enable a limited callback feature for animations that loop. Maybe that would support canceling upon a condition being met, or to alter a behavior such as wrapping the animated property, but I thought that would require a lot of overhead and could mess with timing.

redoak commented 3 months ago

I have had the same issue where I need to chain with the on_complete callback to make the first play-through a special case. It would be convenient to have something like the from property you describe. Additionally, I would like to blend between the pre-animate property state and the animation to get a smooth transition. My idle and walk animations loop scale and rotation tweens, and it's difficult to not get an abrupt jump when transitioning. I'm thinking it could perhaps be improved with special case options for the first play-through.