- Home /
JS Move object over time
When i press a button, an object moves in my game but it moves instantly, i was wondering how to make the transition smoother without using animation
var MyGameObject : GameObject;
if(Input.GetKeyDown("e"))
{
MyGameObject.transform.position.x -= 1;
MyGameObject.transform.position.y += 0.5;
}
Comment
Answer by Digital-Phantom · Mar 27, 2015 at 12:48 PM
Try
var MyGameObject : GameObject;
if(Input.GetKeyDown("e"))
{
MyGameObject.transform.position.x -= 1 * Time.deltaTime;
MyGameObject.transform.position.y += 0.5 * Time.deltaTime;
}
:)