Пример #1
0
    private void Update()
    {
        // calculate player position on screen
        bounds.CalculateBounds(transform.position, 0, 1, 0, 1);

        // get desired movement direction
        moveDir = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        // destroy self when timer expires
        if (shotRange <= 0)
        {
            Destroy(gameObject);
        }

        // countdown timer
        shotRange -= Time.deltaTime;

        bounds.CalculateBounds(transform.position, 0, 1, 0, 1);

        // destroy if off screen
        if (bounds.posOnScreen.x == 0 || bounds.posOnScreen.x == 1 || bounds.posOnScreen.y == 0 || bounds.posOnScreen.y == 1)
        {
            Destroy(gameObject);
        }
    }