I want my cube to move to a other position when i click the mouse button. I know how to script, but i just cant figure out how to do it like this.
How do i achieve this?
Thats quite Simple
Here is an example
public GameObject Object;
public float speed;
public Vector3 DestinationPoint;
bool cango = false;
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
cango = true;
}
if((transform.position - DestinationPoint).sqrMagnitude < 2f)
{
cango = false;
}else{
//Assuming your Starting point is the object's position
if(cango)
{
transform.position = Vector3.Lerp(transform.position,DestinationPoint,Time.deltaTime * speed);
}
}
}