Created
March 15, 2015 22:17
-
-
Save kankikuchi/5c9d0365552788d93707 to your computer and use it in GitHub Desktop.
衝突位置にエフェクトを発生させる【Unity】
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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