Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

unity3d - Why my onTrigger is trigering 3 times, even Destroying the other object in the first line?

My ontriggerenter2D is triggering 3 times(instantiating 3 objects), even with me destroying the other object before everything else.

private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "ShieldPickUp")
        {
            Debug.Log("trigered");
            Destroy(other.gameObject);
            GameObject shieldPU = Instantiate(_shieldPowerUp, transform.position, Quaternion.identity);
            shieldPU.transform.parent = this.transform;
            Instantiate(_shieldTimerSlider, _healthBarCanvas.transform.position + new Vector3(-400, -240, 0), Quaternion.identity, _healthBarCanvas.transform);
            _playerDamager.isPlayerShielded = true;


        }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...