unity3d 3.5 如何检测粒子碰撞

2025-01-03 01:10:31
推荐回答(1个)
回答1:

首先给粒子加上World Particle Collider,然后勾上sendCollisionMessage
然后用function OnParticleCollision (other : GameObject)
{ var body : Rigidbody = other.rigidbody; if (body) { var direction : Vector3 = other.transform.position - transform.position; direction = direction.normalized; body.AddForce (direction * 5); }}
接受碰撞信息,要注意的是,被粒子碰撞的物体需要加collider