衝突した位置情報を取得して、その位置にエフェクトを発生させる方法

衝突位置にエフェクトを発生させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyObject_B : MonoBehaviour {
public GameObject effectPrefab;
void OnCollisionEnter(Collision other){
if (other.gameObject.tag == "Shell") {
Destroy (other.gameObject);
foreach (ContactPoint contactPoint in other.contacts) {
GameObject effect = (GameObject)Instantiate (effectPrefab, (Vector3)contactPoint.point, Quaternion.identity);
// 衝突位置を確認してみる。
print ((Vector3)contactPoint.point);
Destroy (effect, 1.5f);
}
}
}
}

Unity Code Memo
他のコースを見る
衝突位置にエフェクトを発生させる
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyObject_B : MonoBehaviour {
public GameObject effectPrefab;
void OnCollisionEnter(Collision other){
if (other.gameObject.tag == "Shell") {
Destroy (other.gameObject);
foreach (ContactPoint contactPoint in other.contacts) {
GameObject effect = (GameObject)Instantiate (effectPrefab, (Vector3)contactPoint.point, Quaternion.identity);
// 衝突位置を確認してみる。
print ((Vector3)contactPoint.point);
Destroy (effect, 1.5f);
}
}
}
}

衝突した位置情報を取得して、その位置にエフェクトを発生させる方法