I want to move an instantiation of a rigidbody2d(Ship) from one point to another.
Shippos is my point a.
Targetpos is my point b.
They are assigned in the inspector,
The instantiation is triggered by a mouse click on object,
My problem is i can't figure out the right function to use ,Or where to put it
to be able to move my instance ,Or how to control the speed of the movement.
public class Attack : MonoBehaviour {
public Transform ShipPos;
public Transform Targetpos;
public Timer temp;
public Rigidbody2D ship;
public float speed = 4;
public float step;
void start(){
}
// Update is called once per frame
void Update () {
}
void OnMouseDown(){
step = speed * Time.deltaTime;
temp.timeleft /= 2;
for (int i = 0; i < temp.timeleft; i++) {
Rigidbody2D shipinstance;
shipinstance = Instantiate (ship, ShipPos.position, ShipPos.rotation) as Rigidbody2D;
}
}
}