Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Animation control

$
0
0
I have a simple skinned mesh and animation clip. So, using script I start the animation public class AniProc : MonoBehaviour { [...] void Start () { [...] animation.Play("myAnimation"); [...] } void Update () { AnimationState clip = animation["myAnimation"]; Mesh bmesh = new Mesh(); _mesh.BakeMesh(bmesh); Debug.Log(_curFrame + " ### Vector " + bmesh.vertices[10].x + " " + bmesh.vertices[10].y + " " + bmesh.vertices[10].z + " "); _curFrame++; } [...] } This script works just fine. I can see the actual animation on the screen and it prints position of 10th vertex for every frame into console. So, every every frame the position of 10th vertex is different and it is correct. But, no I just add "clip.time = 0.0f;" into my script to force animation time always be 0. The code will looks like this: void Update () { AnimationState clip = animation["myAnimation"]; clip.time = 0.0f; Mesh bmesh = new Mesh(); _mesh.BakeMesh(bmesh); Debug.Log(_curFrame + " ### Vector " + bmesh.vertices[10].x + " " + bmesh.vertices[10].y + " " + bmesh.vertices[10].z + " "); _curFrame++; } So, unity renders only the first frame of the animation and it is correct, but baked mesh contains geometry according to actual time position, i.e. not 0, in other words, it looks like clip.time = 0.0f affects to rendering output, but not to baked geometry. Am I doing something wrong? Thank You!

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>