Jittering when doing animations with PicaVoxel

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):

public class MoveForward : MonoBehaviour
{

    public Rigidbody RigidBody;
    public float movementSpeed = 2.0f;
    public float clockwise = 250f;
    public float counterClockwise = -250f;

    void Start()
    {

    }

    void Update()
    {

         transform.position += transform.forward * Time.deltaTime * movementSpeed;

        if (Input.GetKey(KeyCode.S))
        {
            RigidBody.position -= transform.forward * Time.deltaTime * movementSpeed;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            RigidBody.position -= transform.right * Time.deltaTime * movementSpeed;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            RigidBody.position += transform.right * Time.deltaTime * movementSpeed;
        }

        if (Input.GetKey(KeyCode.E))
        {
            transform.Rotate(0, Time.deltaTime * clockwise, 0);
        }
        else if (Input.GetKey(KeyCode.Q))
        {
            transform.Rotate(0, Time.deltaTime * counterClockwise, 0);
        }
    }
}

I’m wondering: What causes this “jitter”, and how could I get rid of it?

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.

1 Like

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…

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?

1 Like

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!

1 Like