コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        input = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));

        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) ||
            Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) ||
            Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.LeftArrow) ||
            Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.RightArrow))
        {
            UtilityHelper.ChangeRotation(transform, input);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(Dash());
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        // Locking on target
        if (target != null && UtilityHelper.IsGameObjectSleeping(gameObject))
        {
            Vector3 dir = target.position - transform.position;
            UtilityHelper.ChangeRotation(transform, dir);
        }

        if (fireCountdown <= 0f)
        {
            if (UtilityHelper.IsGameObjectSleeping(gameObject))
            {
                Shoot();
            }

            fireCountdown = 1f / fireRate;
        }

        fireCountdown -= Time.deltaTime;
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        enemy.SetDestination(player.position);

        healthBarInstance.value = ReturnHitPoint();

        if (currentHealth <= 0)
        {
            Destroy(gameObject);
            // Drop an upgrade here
        }

        if (healthBarInstance != null)
        {
            SetPositionOfHealthBar(healthBarInstance, transform);
        }

        // Always look at the player
        Vector3 dir = player.position - transform.position;

        UtilityHelper.ChangeRotation(transform, dir);
    }