Skip to content

Instantly share code, notes, and snippets.

@kankikuchi
Created March 15, 2015 22:17
Show Gist options
  • Save kankikuchi/5c9d0365552788d93707 to your computer and use it in GitHub Desktop.
Save kankikuchi/5c9d0365552788d93707 to your computer and use it in GitHub Desktop.
衝突位置にエフェクトを発生させる【Unity】
using UnityEngine;
using System.Collections;
public class Monster : MonoBehaviour
{
//エフェクトのプレハブへのパス
private const string EFFECT_PATH = "Effect/Collision";
void OnCollisionEnter2D (Collision2D collider)
{
//衝突エフェクト
foreach (ContactPoint2D point in collider.contacts) {
GameObject effect = Instantiate (Resources.Load (EFFECT_PATH)) as GameObject;
effect.transform.position = (Vector3)point.point;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment