unity3d 3.5 如何检测粒子碰撞

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 17:46:34
unity3d 3.5 如何检测粒子碰撞

unity3d 3.5 如何检测粒子碰撞
unity3d 3.5 如何检测粒子碰撞

unity3d 3.5 如何检测粒子碰撞
首先给粒子加上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