using UnityEngine; using System.Collections; using System.Collections.Generic; using Obi; [RequireComponent(typeof(ObiSolver))] public class CollisionEventHandler : MonoBehaviour { ObiSolver solver; public Collider killer; void Awake(){ solver = GetComponent<Obi.ObiSolver>(); } void OnEnable () { solver.OnCollision += Solver_OnCollision; } void OnDisable(){ solver.OnCollision -= Solver_OnCollision; } void Solver_OnCollision (object sender, Obi.ObiSolver.ObiCollisionEventArgs e) { for(int i = 0; i < e.contacts.Length; ++i) { if (e.contacts[i].distance < 0.001f) { Component collider; if (ObiCollider.idToCollider.TryGetValue(e.contacts[i].other,out collider)){ if (collider == killer){ ObiSolver.ParticleInActor pa = solver.particleToActor[e.contacts[i].particle]; ObiEmitter emitter = pa.actor as ObiEmitter; if (emitter != null) emitter.life[pa.indexInActor] = 0; } } } } } }
标签:插件,solver,Fuild,void,contacts,using,OnCollision,Obi From: https://www.cnblogs.com/WantPeach/p/18670349