Пример #1
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        Instantiate(explosionPrefab, transform.position, Quaternion.identity);

        //衝突オブジェクトのスクリプトにアクセス
        RockController c = coll.gameObject.GetComponent <RockController>();

        collDebrisType       = c.GetDebrisType();
        collDebrisName       = c.GetDebrisName();
        collDebrisOwner      = c.GetDebrisOwner();
        collDebrisLaunchSite = c.GetDebrisLaunchSite();

        Debug.Log("coll obj:" + collDebrisType);

        //衝突オブジェクトを記録

        State.SetCollDebrisType(collDebrisType);
        State.SetCollDebrisName(collDebrisName);
        State.SetCollDebrisOwner(collDebrisOwner);
        State.SetCollDebrisLaunchSite(collDebrisLaunchSite);


        //衝突オブジェクトと自機を破壊
        Destroy(coll.gameObject);
        Destroy(gameObject);

        //ゲームオーバーシーンに遷移
        SceneManager.LoadScene("GameOver");
    }