コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (GamePause.IsPaused())
        {
            return;
        }


        if (!target == null)
        {
            gameObject.SetActive(false);
        }

        //Mainly for the rocket but, this rotate the bullet as well...
        Vector3 displacement = target.transform.position - transform.position;

        target.transform.rotation = Quaternion.LookRotation(new Vector3(displacement.x, 0, displacement.z));

        Vector3 distanceRemaining = target.transform.position - transform.position;
        float   distanceTraveled  = speed * Time.deltaTime;

        if (distanceRemaining.magnitude > distanceTraveled)
        {
            transform.position += distanceRemaining.normalized * distanceTraveled;
        }
        else
        {
            Hit(target);
        }
    }
コード例 #2
0
    private void OnEnable()
    {
        GamePause.onPause  += OnPause;
        GamePause.onResume += OnResume;

        paused = GamePause.IsPaused();
        if (paused)
        {
            OnPause();
        }
        else
        {
            OnResume();
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (GamePause.IsPaused())
        {
            return;
        }

        if (!target == null)
        {
            gameObject.SetActive(false);
        }

        Vector3 distanceRemaining = target.transform.position - transform.position;
        float   distanceTraveled  = speed * Time.deltaTime;

        if (distanceRemaining.magnitude > distanceTraveled)
        {
            transform.position += distanceRemaining.normalized * distanceTraveled;
        }
        else
        {
            Hit(target);
        }
    }