Jittery Rigidbody2D Movement

58 Views Asked by At

I'm experiencing some jittery issues with rigidbody movement. It's a very simple game with some objects falling from the top of the screen and I just set the velocity in order to move my object but there are some severe jittery even more with high velocity. I'm new with unity and I really don't understand because I just set the velocity once, I don't even update the position of my object during time. I tried to use different moving methods (movePostion, addForce), interpolate/extrapolate but it didn't work even with 60 FPS target frame rate. Here's my code where I spawn the falling objects (caca):

private void Update()
    {
        // pour chaque caca dans la pool
        for (int i = 0; i < CacaPool.instance.cacaQueue.Count; i++)
        {
            spawnPoint = new Vector3(Random.Range(topLeftScreenX, topRightScreenX), topScreenY + 1.5f);
            float speed = Random.Range(3f, 6f) * speedCacaFactor;
            Caca caca = CacaPool.instance.cacaQueue.Dequeue();
            caca.gameObject.SetActive(true);
            caca.SetRandomSize();
            caca.transform.position = spawnPoint;
            caca.GetComponent<Rigidbody2D>().velocity = new Vector2(0, -speed);
            caca.ScheduleReturnToPool(speed);
        }
    }

My caca rigidbody conf : enter image description here Any help or advice would be very much appreciated :)

0

There are 0 best solutions below