Moving an instantiate object with buttons

Hello everyone! I’m trying to create a game where one object at time fall from the sky and i can control them with two button (for movement) the problem is: when I instantiate the object i can’t using Vector3.MoveForward for moving my object when they fall. I’ve setted two function in the object script and in the OnClick() function of the buttons i’ve setted these functions but don’t work…some ideas? These is my code: (For the object)


 using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Oggetto : MonoBehaviour {

    private Rigidbody2D rb2d;
    //private BoxCollider2D bx2d;
    private float vel = 5f;
    private float velrotazione = 5f;
    public Vector3 sx = new Vector3(-2.4f, 8.26f, -2.75f);
    public Vector3 dx = new Vector3(2.4f, 8.6f, -2.75f);

	// Use this for initialization
	void Start () {
        rb2d = GetComponent<Rigidbody2D>();
        //bx2d = GetComponent<BoxCollider2D>();
	}
	
	// Update is called once per frame
	void Update () {
        rb2d.transform.Translate(Vector3.down * vel * Time.deltaTime, Space.World);
        transform.Rotate(Vector3.forward * velrotazione);
    }

    public void SpostaSx()
    {
        Debug.Log("Premuto sx");
        transform.position = Vector3.MoveTowards(transform.position, sx, 10f);
    }

    public void SpostaDx()
    {
        Debug.Log("Premuto dx");
        transform.position = Vector3.MoveTowards(transform.position, dx, 10f);
    }

}

Hi, @Fasertio41!

Try this C# script

using UnityEngine;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {

#region Declaration

[Header("Button right")]
public Button rightButton;

[Header("Button left")]
public Button leftButton;

private Rigidbody2D rb2d;
private float vel = 5f;
private float velrotazione = 5f;

[Header ("transform position vector")]
public Vector3 sx = new Vector3(2.4f, 8.26f, -2.75f);

#endregion

void Start()
{
    rightButton.onClick.AddListener(rightButtonEvent);
    leftButton.onClick.AddListener(leftButtonEvent);

    rb2d = GetComponent<Rigidbody2D>();
}


void Update () {
    rb2d.transform.Translate(Vector3.down * vel * Time.deltaTime, Space.World);
    transform.Rotate(Vector3.forward * velrotazione);
}

#region movement buttons events

/* if you don`t use ui - rename private to public and apply to your object*/

private void rightButtonEvent()
{
    transform.position = Vector3.MoveTowards(transform.position, transform.position - sx, 10f);
}

private void leftButtonEvent()
{
    transform.position = Vector3.MoveTowards(transform.position, transform.position + sx, 10f);
}

#endregion

}