特定の枠の外にでたら弾が消えるようにしたかったのですが、なにか間違いがあるようです。
ドットインストールの動画通りにやったのですが、どこで間違えてしまったのかわかりません。
これまでにおこなった手順は以下の通りです。
Create Empty
Add Component Bow Collider 2D
Is triggerにチェック
Add Component から Box Collider 2D :57
Edit Collider で衝突の範囲を設定
Prefabs の Bullet プレハブを編集していきます。
Add Component から Rigidbody 2D を追加
Body Type を Kinematic に設定
弾に合うように楕円のコライダーを設置
Capsule Collider 2D
Boundary をクリックしてから Inspector でスクリプトを追加
Add Component BoundaryScript作成
Boundaryのスクリプトは以下の通りです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoundaryScript : MonoBehaviour
{
private void OntriggerExit2D(Collider2D collision)
{
Destroy(collision.gameObject);
}
// Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/13 03:58