- 最后登录
- 2014-10-23
- 注册时间
- 2011-7-19
- 阅读权限
- 90
- 积分
- 81303
- 纳金币
- -1
- 精华
- 11
|
Trigger Tips and Caveats
This article mentions a few already, but to recap:
■Other triggers will “collide” with triggers! Use this for invisible triggers that don’t collide with your actual physics (spawn point triggers, etc).
■Triggers do respond to raycasts! Make sure your triggers are set to ignore raycasts, unless you really want to raycast against them.
■An object destroyed inside of a trigger will not fire OnTriggerExit. If you track objects be wary of this. The only sure way to count objects currently inside of a trigger is to use OnTriggerStay
■Triggers are fast! Use them! Even in non-physical games you will see speed increases. For example, you could have a tower defense game where your enemies are kinematic rigidbodies and turrets track targets in range using triggers.
■There is a penalty for moving static colliders (a Collider with no Rigidbody component). If you want to move your trigger around, add a Rigidbody and set it to be kinematic.
■Triggers are great on the iPhone, since everything happens in highly optimized PhysX. You’d be surprised.
Example Project
The above-mentioned scripts are included in a quick example project (so don’t worry about copying and pasting off the post).
Other Uses?
How have you guys been using triggers? Share your own tips and tricks in the comments!
由 u8 发表
转自老外博客 |
|