示例#1
0
 void Update()
 {
     if (canMove)
     {
         if (Input.GetKey(KeyCode.W))
         {
             transform.Translate(Vector3.up * Time.deltaTime * 5);
         }
         if (Input.GetKey(KeyCode.S))
         {
             transform.Translate(Vector3.down * Time.deltaTime * 5);
         }
         if (Input.GetKey(KeyCode.A))
         {
             transform.Translate(Vector3.left * Time.deltaTime * 5);
         }
         if (Input.GetKey(KeyCode.D))
         {
             transform.Translate(Vector3.right * Time.deltaTime * 5);
         }
         if (Input.GetKeyDown(KeyCode.Space))
         {
             SaveIsEasy.PrefabInstantiate(cube, transform.position, Quaternion.identity);
         }
     }
     else
     {
         transform.Rotate(Vector3.forward * Time.deltaTime * speed);
     }
 }
示例#2
0
    void Update()
    {
        if (Random.Range(1, 70) == 1)
        {
            GameObject newObject = SaveIsEasy.PrefabInstantiate(Prefab);
            newObject.transform.position = transform.position + new Vector3(Random.Range(-10, 10), 0, 0);
        }

        time += Time.deltaTime;
    }