Coder Social home page Coder Social logo

Comments (15)

loodakrawa avatar loodakrawa commented on August 11, 2024 1

This is the intended behaviour. What happens is, animations get interpolated based on a normalised progress. In this example:

Animation A is at 700/1000 ms or 0.7 progress
You transition to B with a 100ms interval.
Animation B starts at 0.7 progress or 600 * 0.7 == 420ms.

Usually, the transitions happen between animations such as walking/running/jumping and this behaviour makes them look more natural. On the other hand, attack animations are usually jumped into straight away i.e. no interpolation.

That being said, this use case is completely valid and I believe the right solution is to expand the interpolation methods with an enum to specify the interpolation mode. Something like:
InterpolationMode.CurrentProgress
InterpolationMode.FromStart

from spriterdotnet.

alextilkin avatar alextilkin commented on August 11, 2024 1

Thanks for the info. I think I came up with a pretty clean solution that loses the normalized transitions, but just uses simple transitions that work more like you'd expect for attacks and whatnot. If anyone else runs into this in the future, here is what I did:

At line 192 in the Animator class, I changed

if (NextAnimation != null && totalTransitionTime != 0.0f)
{
	elapsed += elapsed * factor * CurrentAnimation.Length / NextAnimation.Length;
	transitionTime += Math.Abs(elapsed);
	factor = transitionTime / totalTransitionTime;
	if (transitionTime >= totalTransitionTime)
	{
		float progress = Progress;
		Play(NextAnimation.Name);
		Progress = progress;
		NextAnimation = null;
	}
}

Time += elapsed;

to

if (NextAnimation != null && totalTransitionTime != 0.0f)
{
	elapsed += elapsed * factor * CurrentAnimation.Length / NextAnimation.Length;

	transitionTime += Math.Abs(elapsed);
	factor = transitionTime / totalTransitionTime;
	if (transitionTime >= totalTransitionTime)
	{
		//float progress = Progress;
		Play(NextAnimation.Name);
		Progress = 0;// progress;
		NextAnimation = null;
	}
}
else
{
	Time += elapsed;
}

and in FrameDataCalculator at line 34 I changed

float targetTimeSecond = targetTime / first.Length * second.Length;

to

float targetTimeSecond = 0;

Basically, all it does is have animations transition from the current animation to the start of the next animation.

from spriterdotnet.

rfadeev avatar rfadeev commented on August 11, 2024

Could you please provide Spriter project and code snippet you use to make a transition to be able to reproduce the issue?

from spriterdotnet.

KamiGrave avatar KamiGrave commented on August 11, 2024

WeeKnights.zip

The code is just the MonoGame example from this repository. I had to edit the Constants file to add the scml file.
I also edited the transition time in the ExampleGame.cs to be 100, instead of 1000. (line 103)

from spriterdotnet.

KamiGrave avatar KamiGrave commented on August 11, 2024

I did a custom solution which basically involved me passing through the transition time and using that for getting the second animation frames. It's a bit of a hack for the moment to get things working (No idea what would happen if the transition time was longer than the target animation, I guess it would just hang at the last frame or loop).
I am using the transitions to smooth out the move from one attack to another in a combo system, the attacks are data driven so creating bespoke animations isn't really an option. The hack I've done to the transition logic appears to be working for me, but it's not a very clean solution as you basically lose the ability to interpolate using the normalised progress as before.

from spriterdotnet.

alextilkin avatar alextilkin commented on August 11, 2024

I'm running into this issue, and I can't seem to come up with a good way of transitioning to attack animations. I tried KamiGrave's solution but it doesn't really fix the problem completely for me. I'd be happy to give up the normalized transitions entirely if I could get it to cleanly transition to the start of animations. The way things are set up now transitions are basically useless for anything like an attack.

from spriterdotnet.

KamiGrave avatar KamiGrave commented on August 11, 2024

@luciddream00 The solution I came up with was a bit of a hack and is in my own fork of the SpriterDotNet repo. There's probably a much cleaner solution that I didn't look for under the expectation that this may be fixed at some point in the main repo (this one) and I didn't want to clash with it. In retrospect, I should probably have introduced a clean solution and set it up for a pull request.
As it happens, I'm no longer using SpriterDotNet or MonoGame, but this was one issue I resolved before moving onto an engine.
It should be noted as well that I had to modify the animations as well because of the transition time from one attack to the other. There was also issues about events firing during the transitions that made things a bit difficult too.

from spriterdotnet.

Martenfur avatar Martenfur commented on August 11, 2024

@luciddream00 Thanks, this absolutely solved transition issues. This should really be the default behavior, I dunno why the author thinks janky transitions are better.

from spriterdotnet.

loodakrawa avatar loodakrawa commented on August 11, 2024

@luciddream00 Thanks, this absolutely solved transition issues. This should really be the default behavior, I dunno why the author thinks janky transitions are better.

I did it so people like you, who have nothing better to do than criticizing open source projects instead of actually contributing, have something to do.

from spriterdotnet.

Martenfur avatar Martenfur commented on August 11, 2024

I did it so people like you, who have nothing better to do than criticizing open source projects instead of actually contributing, have something to do.

I mean. I could make my fork public and submit my changes, if you wanna. But you probably won't like them and won't merge them anyway, since you got pull requests open for two years.

from spriterdotnet.

loodakrawa avatar loodakrawa commented on August 11, 2024

I did it so people like you, who have nothing better to do than criticizing open source projects instead of actually contributing, have something to do.

I mean. I could make my fork public and submit my changes, if you wanna. But you probably won't like them and won't merge them anyway, since you got pull requests open for two years.

You are probably right. Based on the lack of understanding you showed when you opened other issues in the past few days I highly doubt your code would improve this project in any way.

from spriterdotnet.

alextilkin avatar alextilkin commented on August 11, 2024

For what it's worth, I very much appreciate the library even if I had to fiddle with it a bit to act the way I want.

from spriterdotnet.

loodakrawa avatar loodakrawa commented on August 11, 2024

For what it's worth, I very much appreciate the library even if I had to fiddle with it a bit to act the way I want.

I'm very glad to hear that. That was my main motivation to go open source in the first place - hopefully help someone with the code I planned to write for myself anyway. I am trying to maintain it and improve it, but sometimes it's difficult to give it all the love it deserves due to, well, life happening. Since I'm already working on version 2 (albeit slowly) which is almost a complete rewrite, I'm less active in improving the current version since I'll address all these things (like this issue) directly in the next version.

from spriterdotnet.

Martenfur avatar Martenfur commented on August 11, 2024

You are probably right. Based on the lack of understanding you showed when you opened other issues in the past few days I highly doubt your code would improve this project in any way.

Your tendency to overengineer and my degree of understanding don't have much in common, tbh.
And damn, why so salty? I am genuinely trying to help your thingy and you're behaving like a total dick.

from spriterdotnet.

loodakrawa avatar loodakrawa commented on August 11, 2024

You are probably right. Based on the lack of understanding you showed when you opened other issues in the past few days I highly doubt your code would improve this project in any way.

Your tendency to overengineer and my degree of understanding don't have much in common, tbh.
And damn, why so salty? I am genuinely trying to help your thingy and you're behaving like a total dick.

You've been nothing but rude and condescending and you haven't suggested a single useful thing. If this is your way of "trying to help", go do it somewhere else.

from spriterdotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.