Animations behaving a bit funny on the device

Hello,

I’m currently experiencing some very vexing animation issues. Animations I have set up will play fine in the editor, but on the device behave inconsistently. Weirdness like animations not playing all the way through, or not playing at all, have been cropping up.

To give an example, I have an animation fbx exported from Maya that consists of little people and cars moving around. In the scene, it’s placed in such a way that they look like they’re boarding a ferry which is docked (basically they move so they’re inside the ferry mesh and obscured from view, and then sink down out of sight below the water). The animation component has this boarding animation set as the default, and the wrap mode is set to Once. To fire off the animation, I’m doing a simple animation.Play() command. In the editor, it works fine. The animation plays all the way through, and the people cars move down out of sight after boarding. When the ferry moves off, they’re out of the way and can’t be seen.

When run on a device, however, the animations seem to not play all the way through sometimes. I’ve had instances where the ferry has departed, and the cars and people are still clumped together where the ferry was, rather than sitting below the water where they’re not visible.

Another thing has to do with animations I have placed on the ships themselves, though it’s more involved and I suspect I’m doing something incorrectly. Basically what I’m trying to accomplish is:

A ship moves into a dock from offscreen. When it docks, a player loads it with cargo. While loading, the ship plays an animation of cargo appearing on its deck, and it gets lower in the water. At any time during this process, the player can choose to send the ship back out. If the ship is still loading cargo, it should stop its loading animation where it is, so it will show a partial load of cargo on deck and only partially be lowered in the water, and then animate back off screen. The ship should then reset to its original idle state having no cargo and being high in the water, because it is used again to represent a new ship pulling into the dock.

The ship object I have set up is an fbx from Maya that I split into two clips, based on animations the 3d artist created. The first two frames of its animation are an “idle” animation, which consists of the ship sitting high in the water. The rest of the animation frames are the ship’s “fill” animation, which shows the ship loading cargo and lowering. I have animation states defined for these two clips in my code, and their wrap modes set to Once.

When I bring a ship into dock, I do the following:

shipAnim.Play("idle");

to make sure the ship is in its idle state. When a player starts loading cargo onto the ship, I start the fill animation:

shipAnim.Play("fill");

If the player lets the ship load all the way, the animation reaches its endpoint and stops, with the ship showing as fully loaded and low in the water. If the player sends the ship out prematurely, I call:

shipAnim.shipAnim.Stop();

to stop the animation where it is.

In the editor, this all works fine. The ships come in empty, they dutifully load cargo and stop midway if sent out early, and they leave the screen and come back in empty as a new ship. However, on the device I run into all sorts of weirdness. Ships will come in however full they were when they left, and sometimes the “fill” animation will only play halfway and stop.

Has anyone else run into things like this?

I know this may sound weird, but try this. In the editor, maximize the game view when you play (so there is no visible scene view). Do you see the problem in the editor then?

Just tried this, and no, the problem doesn’t show up if I maximize the game screen. It still runs fine in the editor.

Well, the symptom you are describing seems like a problem with Disable Animation When Offscreen on the Skinned Mesh Renderer component, but the problem should also happen in the editor then if there is nothing but the game view visible. I suppose you might still try it.

On your Skinned Mesh Renderer component, make sure there is no reference (“none”) in the Disable Animation When Offscreen field.

I had the same sort of problem with animations not necessarily playing all the way through… after a lot of trying to fix it in code, I took the easy way out:

Pad the end of the sticking animations with extra frames.
It seems almost like it’s playing to the end minus a few frames, so adding more duplicate frames at the end fixed this problem for me. Not the most desirable, but it works.

As for the second problem… yes - that does seem more involved - good luck!

It was indeed on in the models, so I did a build with that option turned off. Unfortunately, the behavior remains the same. :frowning:

As an update, the artist added extra keyframes to the end of one of the animations so we could test it. Unfortunately, the animation still seems to stick when played back on the device.

Any other ideas on this? Help is much appreciated. :slight_smile:

hum, actually i’m experiencing same kind of problems. Have found some ways around but they are very inelegant (as forcing the animation to last frame after a lapse of time) and would love to learn about the “real” solution and what i’m doing wrong.

I have the same problem, with at least one animation created from code (a screen-wipe animation doesn’t close all the way). It’s just a little bit off running in a web player, but much more pronounced on an iPhone. It’s on my worry-about-it-later queue, but I’m glad to know it’s not just me!

We ended up working around it by creating a 2-frame idle animation and playing that to reset the animation.

Good to know I’m not the only one running into this problem.

I’ve run into this problem with animations before. Try setting the play mode to “Clamp forever” (when finished playing) I’m not sure if this eats processor time, but it seems to have fixed my animation troubles.

Thanks tinrocket, I checked my wrap mode and saw it was set as Default. I switched it to Once and that fixes it in the web player, but I’m optimistic it will help on the iPhone, too. (I also had Play Automatically incorrectly set, but that seems less likely to be part of the problem).

Well, in my case, the wrap mode was already set to Once and I was still experiencing weirdness. Maybe you’ll fare better, though. :slight_smile:

Hey guys,

I didn’t have this problem and thought you were all crazy.

Then I got this problem out of nowhere (boo!), and the problem was resolved by setting the Wrap Mode to ‘ClampForever’…

“Clamp” did not fix it.

Previous it was set to ‘default’.

So far as I could tell, I was not able to replicate the problem without compiling to the device (ie - the Mac was too mighty and powerful to run into such problems, heh)

That should a be status/resolution in the bug database - “You’re crazy”

I thought Once vs. Default was improving it enough, but then I still saw the problem on old Mac mini. Seems like it gets correspondingly worse on slower machines. ClampForever seems to fix it (on the list for the next iPhone app upgrade!)

Since I actually needed to be able to interact with the object, I ended up changing the clamp mode on the fly… Before I’d play an animation, i’d just…

weapon.animation.wrapMode = WrapMode.ClampForever

And after an animation had played and I was allowing transform modification of the object (ie, it won’t move when its in ClampForever) i just set it to WrapMode.Once :slight_smile:

Yes, a workaround. Meh :slight_smile: