开启辅助访问
 找回密码
 注册帐号

扫一扫,访问微社区

collider.oncollisionstay 逗留碰撞

2015-1-4 17:57| 发布者: 杨炎| 查看: 2158| 评论: 0|原作者: 蛮牛|来自:

摘要 : collider.oncollisionstay 逗留碰撞functiononcollisionstay(collisioninfo: collision) : voiddescription描述oncollisionstay is called once per frame for every collider/rigidbody that is touching rigidbody ...

collider.oncollisionstay 逗留碰撞

functiononcollisionstay(collisioninfo: collision) : void

description描述

oncollisionstay is called once per frame for every collider/rigidbody that is touching rigidbody/collider.

每个collider/rigidbody触动rigidbody/collider,将在每帧调用oncollisionstay。通俗的说,

一个碰撞器或刚体触动另一个刚体或碰撞器,在每帧都会调用oncollisionstay,直到它们之间离开不接触。

in contrast to ontriggerstay, oncollisionstay is passed thecollisionclass and not a collider. thecollisionclass contains information about contact points, impact velocity etc. if you don't use collisioninfo in the function, leave out the collisioninfo parameter as this avoids unneccessary calculations. note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.

相比ontriggerstay,oncollisionstay传递collision类而不是collider。collision类包含接触点,碰撞速度等信息。在这个函数如果你不使用collisioninfo,删去collisioninfo参数以避免不必要的计算。注意,当其中至少一个碰撞盒附加非动力学刚体时碰撞事件才会发送。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

void oncollisionstay(collision collisioninfo) {

foreach (contactpoint contact in collisioninfo.contacts) {

debug.drawray(contact.point, contact.normal * 10, color.white);

}

}

}

function oncollisionstay(collisioninfo : collision) {

// debug-draw all contact points and normals

//调试绘制全部接触点和法线

for (var contact : contactpoint in collisioninfo.contacts) {

debug.drawray(contact.point, contact.normal * 10, color.white);

}

}

0 0 0 0 0

相关阅读

最新评论

返回顶部