Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //Get normalized direction vector and move the player
        direction = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0f);
        direction.Normalize();
        transform.position += direction * moveSpeed * Time.deltaTime;


        if (Input.GetButtonDown("Fire1"))
        {
            gameObject.GetComponent <Weapon>().Fire();
        }

        if (Input.GetButtonDown("Fire2"))
        {
            enemy.SetActive(true);
            enemy.transform.position = new Vector3(0, 5, 0);
        }

        if (Input.GetButtonDown("Jump"))
        {
            var powerup = PowerupController.GetAvailble();
            powerup.gameObject.SetActive(true);
            powerup.transform.position = new Vector3(Random.Range(-10, 10), 10, 0);
        }
    }