This file contains 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.Generic ;//Use :System.Collections.Generic.List<>. | |
//ChildrenのDurationにも対応したパーティクル自動削除スクリプト | |
[RequireComponent(typeof(ParticleSystem))] | |
public class AutoDestoryPartcles : MonoBehaviour { | |
// Use this for initialization | |
void Start () { |
This file contains 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 ; | |
[RequireComponent(typeof(ParticleSystem))] | |
public class AutoDestoryPartcle : MonoBehaviour { | |
void Start () { | |
ParticleSystem partcleSystem = GetComponent<ParticleSystem>() ; | |
//Delete object after duration. | |
Destroy(gameObject,(float)partcleSystem.main.duration ) ; | |
} |
This file contains 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
[SerializeField] | |
GameObject partclePrefab = null ;//inspector上でParticleSystemがアタッチされたGameObjectを設定してください。 | |
//関数名は仮定義 関数で使わなくとも,Instantiateを呼び出している部分を差し替えしてもよい. | |
// その際,Instantiateの第二引数以降は差し替え前のものを使用すること. | |
void AutoDestroyInstantiate(){ | |
Destroy(Instantiate(partclePrefab),partclePrefab.GetComponent<ParticleSystem>().main.duration ) ; | |
} |
This file contains 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
//Update内でPositionに加算するなりしてください。 | |
Vector3 vecocity = new Vector3(0,0,0); | |
//衝突したとき の イベント | |
private void OnCollisionEnter(Collision collision) | |
{ | |
Vector3 normal = Vector3.zero ; | |
//法線ベクトルを取得 |