Ignore physics after collision in unity3d(2d)

和自甴很熟 提交于 2019-12-11 04:23:54

问题


How can I force Unity to not change the speed and direction of objects after collision? I need to get OnCollisionEnter2d event, but I don't need to automatically change speed and direction; I want to do it manually.


回答1:


I need to get OnCollisionEnter2d event, but i dont need to automatically change speed and direction, because i want to do it manually

If you don't want to affect the Object when it collides with another Object, you need to mark the Collider as Trigger.

After this, use the trigger function instead of the collision functions.

void OnTriggerEnter2D(Collider2D other) 
{

}

It will detect that the Objects collided it won't move them. You can then manually move them however you want.



来源:https://stackoverflow.com/questions/45773283/ignore-physics-after-collision-in-unity3d2d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!