Hey guys,
I want to move an object from one position to another fluently. Lets say I want to move an object from current coordinates to new position (3, 1, 5) upon pressing up key once (not by holding it). I’m new to C# so I’m sorry for probably stupid and simple question ![]()
My script looks like this:
void Update ()
{
if (Input.GetKeyDown(“up”))
{
transform.position = Vector3.MoveTowards (transform.position, new Vector3 (3, 1, 5), 1f * Time.deltaTime);
}
}
I guess the problem is the transform.position command executes just once (when i press up key), problem is i don’t know how to tell unity to keep changing the position after i once press that “up” key until object hits those (3,1,5) coordinates.
I’ll appreciate any help ![]()
Ty
B.