Sprite after animation
Asked Answered
S

3

0

Hello,

My games hero is supposed to have several animations and 1 state as idle. The problem is that after any animation played, the heroes image goes back to default, but I need it to be the last frame of animation. I tried to set it in runtime like

public Sprite RightBottomImage;
...
spriteRenderer.sprite = RightBottomImage;

But it gave to result.
Any thoughts?

Sobel answered 2/2, 2024 at 19:12 Comment(0)
Z
0

An idea is that the animation needs work. I’m not criticizing, but animations usually work unless there is a glitch in the animation. Possibly trying to slightly change the code or looking for syntax errors will help you fix the animation.

Zephan answered 3/1, 2014 at 0:6 Comment(1)

The point is that the animation plays well and there is no code do manipulate with it. The animation was made with the native means of Unity (set of frames) and nothing else (but triggers on the last frame, where the log message is displayed). And after the last frame is played, the object`s image is back to default. The code above was my try to fix this with no success

Sobel
F
0

Any solutions? I have the same problem.

Freedman answered 2/2, 2024 at 8:55 Comment(0)
M
0

The Animator will override the sprite (or any other parameter) set in the inspector or any sprite set in code. So I don’t think you can use code to change the sprite while the Animator has control.

Can you try zooming out on the animation timeline to make sure there is not an extra keyframe at the end which changes the sprite back to default? I’ve noticed that Unity will often add an extra keyframe at the end whenever I add a new parameter to the Animator. I’m not sure why.

Mistreat answered 2/2, 2024 at 17:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.