纳金网

标题: unity3d中Trigger的使用探讨(三) [打印本页]

作者: 会飞的鱼    时间: 2011-12-14 14:44
标题: unity3d中Trigger的使用探讨(三)
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  发表
转自老外博客
作者: 奇    时间: 2012-2-18 23:31
好,真棒!!

作者: 菜刀吻电线    时间: 2012-4-21 23:20
不错哦,顶一下......

作者: 奇    时间: 2012-4-25 23:20
加精、加亮滴铁子,尤其要多丁页丁页

作者: 菜刀吻电线    时间: 2012-6-3 23:20
其实楼主所说的这些,俺支很少用!

作者: 菜刀吻电线    时间: 2012-6-8 23:26
真不错,全存下来了.

作者: 菜刀吻电线    时间: 2012-8-20 23:26
先顶上去,偶要高亮加精鸟!

作者: 晃晃    时间: 2012-9-28 23:19
好可爱的字,学习了

作者: 菜刀吻电线    时间: 2012-11-8 23:20
真不错,全存下来了.





欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5