Answer the question
In order to leave comments, you need to log in
Why doesn't the square want to move?
Here is the code, there are no errors. The script weighs on lighting in obj the cube is inserted. 2d game
public GameObject obj;
private GameObject inst_obj;
[SerializeField]
private float speed = 4f;
// Start is called before the first frame update
void Start()
{
inst_obj = Instantiate(obj, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject;
}
// Update is called once per frame
void Update()
{
float zPos = Input.GetAxis("Vertical");
inst_obj.transform.Translate(Vector3.forward * speed * zPos * Time.deltaTime);
}
Answer the question
In order to leave comments, you need to log in
Well, and Vector3.forward is the same in z, change it to up, left, right, down. These are y, x respectively.
And it turns out that he changes z, but does not move
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question