- Home /
Any way to make Animation.Play take effect immediately?
First of all: This is NOT about how to avoid transitions between animationStates.
Now, the issue at hand:
I am coding a doom-style game with multi-directional sprites and multiple cameras. That means that I use OnPreRender on each camera to make each sprite face the camera. So far, so good. Now I I also need to play the right animation for each camera. For example, "Idle" has 8 seperate states/clips for each of the 8 viewing angles. Problem is the frame execution order.
First, All Animations are updated Only then is the scene rendered.
In OnPreRender, I call Animatior.Play to play the correct viewing angle state. Unfortunately, this only takes effect in the next frame so the sprite as it is rendered is always in the state of the last Camera's OnPreRender call,
Example:
Frame 0:
[OnPreRender]
Camera 1:
Play anim for camera angle 1
Camera 2:
Play anim for camera angle 2
Frame 1:
[Animaton Update]
Animation for camera angle 2 (last one played) takes effect
[OnPreRender]
Camera 1:
Play anim for camera angle 1 (takes effect in next frame!)
Camera 2:
Play anim for camera angle 2 (takes effect in next frame!)
[Render]
Camera 1:
Renders sprite, which is playing viewing angle 2 animation
Camera 2:
Renders sprite, which is playing viewing angle 2 animation
Is there any way to make the animation play immediately so it can get rendered, without having to wait for the next frame's animation update phase? The only other solution I can think of is to have seperate sprites for each camera.
Answer by tormentoarmagedoom · Apr 08, 2018 at 07:52 AM
Good day.
There is an option to play automaticly once the object is instantiated.
Byee :D