- Home /
How to I make an object move faster?
I'm making this maze game as a trial game and then see where it goes, but I can't figure out how to make an object (the player) move faster. I gone on several site and even checked on this site but i just can't seem to find the answer. If someone can help me with this i would truly be grateful.
How you move the object, can you post your script that has the movement?
Answer by fun4foes · Oct 09, 2016 at 06:17 PM
using UnityEngine; using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime, 0f, Input.GetAxis("Vertical") * Time.deltaTime);
}
}
@lilius this is the script that i am using for movement
using UnityEngine; using System.Collections;
public class NewBehaviourScript : $$anonymous$$onoBehaviour {
public float speed = 5;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(Input.GetAxis("Horizontal") * speed * Time.deltaTime, 0f, Input.GetAxis("Vertical") * speed * Time.deltaTime);
}
You were moving by using Time.deltaTime (1 unit per second.) so you must create another variable (speed), and multiply it by Time.deltaTime.
In this case It'll move 5 units per second.