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

编程入门 行业动态 更新时间:2024-10-24 12:27:46
本文介绍了unity3d(2d)中的碰撞后忽略物理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何强制Unity在碰撞后不更改对象的速度和方向?我需要获取OnCollisionEnter2d事件,但不需要自动更改速度和方向;我想手动操作.

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.

推荐答案

我需要获取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.

更多推荐

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

本文发布于:2023-06-04 19:12:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/503402.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:物理   unity3d

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!