Vector2.MoveTowards script behaves weirdly on a non-UI object rather than when used on UI object

First thing, for clearance, i call gameobject to items that are outside the Canvas parent. I dont know the correct term.

When I am using Vector2.MoveTowards on an UI element, it behaves like it should be; Not jittering, smooth moving. But when i use it on non-UI object, the object does not move towards the ‘target’ location, instead it jitters as if repeating the command continuously.

I might be using the wrong script, if anybody can help me find a replacement for the Vector2.MoveTowards it’ll be very appreciated.

I haven’t found any problems with MoveTowards so it may be your code. If you let us see it, we can comment. Here is a version which works well:

using UnityEngine;

public class Test : MonoBehaviour
{
    float speed = 5;
    Vector2 target = new(5, 5);
    bool startMove = false;

    void Update()
    {
        float move = speed * Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.Space))
            startMove = true;

        if (startMove)
            transform.position = Vector2.MoveTowards(transform.position, target, move);
    }
}

You will see that I’ve put in a wait for the space key to be pressed before moving. That’s so the initial performance hit of starting to play can be ignored. Attach this script to a sprite and it will move smoothly enough.