set animation point before Camera.Render()

I’m using Camera.Render to capture an image of a character, but I need the animation to be at a specific point.
I’ve tried variations of:
char.animation.Play(“Idle”, PlayMode.StopAll);
char.animation[“Idle”].time = timepoint;
char.animation.Sample();
//do render

but the character never updates before I render to texture. Perhaps it has to wait for the next Update but this is not possible for me to do.
Solution?

bump!

I never did sort out how to do this - it was suggested I use SampleAnimation but that appears to do nothing. doing the first post code works but next frame, not when I do a Camera.Render straight after.
So HELP?

I have the exact problem - probably inventing the same wheel you are :slight_smile: To be super clear this is in an Editor script.

I sample the animation either by excessively setting up the Animation state like so:

theObject.animation.cullingType = AnimationCullingType.AlwaysAnimate;
theObject.animation.clip = theObject.animation[animationToSample].clip;
theObject.animation[animationToSample].speed = 1.0f;
theObject.animation[animationToSample].blendMode = AnimationBlendMode.Blend;
theObject.animation[animationToSample].weight = 1.0f;
theObject.animation[animationToSample].normalizedTime = ( (float) i / (float)frameCount);
theObject.animation[animationToSample].enabled = true;
theObject.animation.Sample();
theObject.animation[animationToSample].enabled = false;

Or I have also tried this:

theObject.SampleAnimation(theObject.animation[animationToSample].clip, ( (float) i / (float)frameCount));

When triggered from an Editor Window button - both of these do what I expect. The anim jumps to the right time (given a valid i and frameCount)

However when triggered in a loop and rendering with a camera to a render texture (I’m using a scriptable wizard)… The animation will NOT be changed. Sometimes I see a T-Pose, sometimes one frame of the anim. I notice that if the animation has any root motion, I see that the T-Pose character moves around in an odd manner but none of the skinned verts appear to be moved :wink:

Another data point is that after my loop is done rendering frames to the render target, the pose in the editor seems to be the correct “last” frame of the animation… Just not during the frame capture process.

I can correctly capture image strips of non-animated objects, but animated ones are giving me fits. Is there a flush()? I’ve tried EditorUtility.SetDirty() as well. No luck.

Any help would be appreciated.

Edit: Doh! Ancient thread, I’d get a “Necromancer” badge on StackOverflow for bringing up such an old thread - but no newer thread has more info that I found :wink: