且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

unity3d(2d)中的碰撞后忽略物理

更新时间:2021-09-12 21:53:09

我需要获取OnCollisionEnter2d事件,但我不需要 自动更改速度和方向,因为我想这样做 手动

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.