Search Unity

Jittering when doing animations with PicaVoxel

Discussion in 'Animation' started by DanielGilbert, Jun 3, 2017.

  1. DanielGilbert

    DanielGilbert

    Joined:
    Feb 14, 2015
    Posts:
    11
    Hi folks,

    I'm currently prototyping, and I have a issue I cannot solve, or better - I don't know what's happening.

    Have a look at this video, and the feets starting in 00:17:



    Basically, I have some kind of jittering or glitch. Now, this is an animation made with MagicaVoxel, imported with PicaVoxel. PicaVoxel creates a mesh for every frame, and then displays them one after another.

    This is how I currently move the character forward (basic script, found in the web some long time ago):

    Code (CSharp):
    1. public class MoveForward : MonoBehaviour
    2. {
    3.  
    4.     public Rigidbody RigidBody;
    5.     public float movementSpeed = 2.0f;
    6.     public float clockwise = 250f;
    7.     public float counterClockwise = -250f;
    8.  
    9.     void Start()
    10.     {
    11.  
    12.     }
    13.  
    14.     void Update()
    15.     {
    16.  
    17.          transform.position += transform.forward * Time.deltaTime * movementSpeed;
    18.  
    19.         if (Input.GetKey(KeyCode.S))
    20.         {
    21.             RigidBody.position -= transform.forward * Time.deltaTime * movementSpeed;
    22.         }
    23.         else if (Input.GetKey(KeyCode.A))
    24.         {
    25.             RigidBody.position -= transform.right * Time.deltaTime * movementSpeed;
    26.         }
    27.         else if (Input.GetKey(KeyCode.D))
    28.         {
    29.             RigidBody.position += transform.right * Time.deltaTime * movementSpeed;
    30.         }
    31.  
    32.         if (Input.GetKey(KeyCode.E))
    33.         {
    34.             transform.Rotate(0, Time.deltaTime * clockwise, 0);
    35.         }
    36.         else if (Input.GetKey(KeyCode.Q))
    37.         {
    38.             transform.Rotate(0, Time.deltaTime * counterClockwise, 0);
    39.         }
    40.     }
    41. }
    I'm wondering: What causes this "jitter", and how could I get rid of it?
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Did you see this jitter before connecting the character to the controller?

    So - I would trouble shoot this by first importing the model into the game and viewing the animation alone. Then getting the animation to work in the game with a simple state machine. Then attaching a simple move script, for only that forward animation, not a complete controller.

    If these steps result in no issues - the problem is in the character controller code. I'm not a programmer so I can't help in that area.
     
    DanielGilbert likes this.
  3. DanielGilbert

    DanielGilbert

    Joined:
    Feb 14, 2015
    Posts:
    11
    Thanks for your reply!

    Yeah, you are right: This only happens as soon as the character moves forward. It looks like it's out of sync or sth...
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hmm - maybe it is a result of the way the animation is created, not syncing with the framerate of the game?
    What framerate did you create the animation at?

    Since the game is a variable framerate - I don't know - this is beyond my knowledge - can the framerate of the game be locked at a specific rate (60fps) so then the animation could match the frame rate of the game exactly?
     
    DanielGilbert likes this.
  5. DanielGilbert

    DanielGilbert

    Joined:
    Feb 14, 2015
    Posts:
    11
    That's an interesting idea. I had 21 single frames, running with a stepping of 0.048 per frame. Yes, I tinkered around with different types of settings. But for now, I guess there are too many parameters that might cause the issue, or at least influence it.

    At the end, I think it might not be worth the hassle. I'll go the good ol' rigging route, although it would have looked cool from what I saw. Thanks for your help so far!
     
    theANMATOR2b likes this.