unity 2d move object to position code example
Example 1: move gameobject in unity 2d
transform.position = new Vector3(transform.position.x + movespeed, transform.position.y);
Example 2: how to move towards an object unity
Vector3.MoveTowards(transform.position, taretPos, Qiaternion.identiy)
Example 3: unity movetowards 2d
private void Move(Vector3 target, float movementSpeed)
{
transform.position += (target - transform.position).normalized * movementSpeed * Time.deltaTime;
}
Example 4: move to where it facing unity 2d
transform.up