Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Gorotoro on July 14, 2014, 12:54:18 AM

Title: Swap 2D sprite animation randomly?
Post by: Gorotoro on July 14, 2014, 12:54:18 AM
So I'm doing my game in 2D, using sprite sheet based animation.  This is what I'm trying to achieve:

-Character stands in the middle of the screen, and by default will perform an "Idle" animation

-After a set # of loops, I want a random animation to play.  I have several that I'll be creating, so any of the group will do.


My questions:

- Is there a command to swap out the animation, using Playmaker? 

- What is the best way to set this up?  I have one animation in the scene right now, but how will Unity know to remove that one and replace it with another, at the exact same coordinates? 

- Should I create an empty object that is then dynamically filled/replaced with animations, when need be?

If anyone has experience with using Unity 2D in this fashion, I'd love to hear your thoughts.

Thanks in advance!
Title: Re: Swap 2D sprite animation randomly?
Post by: jeanfabre on July 14, 2014, 08:08:53 AM
Hi,

I would use the following technics.

The scripting can be also achieved with PlayMaker, ( check out the PlayMaker wiki for unity 2d and mecanim support)

Bye,

 Jean
Title: Re: Swap 2D sprite animation randomly?
Post by: mikejkelley on July 22, 2014, 12:53:45 AM
What's the length on RANDOM6?
Title: Re: Swap 2D sprite animation randomly?
Post by: mikejkelley on July 23, 2014, 12:45:42 PM
It's usually my experience that the problem is with some animation setting rather than playmaker. I don't have too much 2D experience. At first I was going to suggest that if the animation was especially short than the blend time might be enough to completely invalidate playback. Wouldn't think that's the case if it's 1+ second long though. Not sure if/how blend times affect 2D stuff.

In any event, I imagine its some sort of animation parameter.