Collision or movement Bug (Unity 2D game dev)
Collision or movement Bug (Unity 2D game dev)
在相对较高的速度下,碰撞中的角色进入BoxCollider和RigidBody2D内部
尝试将 RigidBody
的 Collision Detection
设置为 Continuous
。
Unity 中的变换移动对象(传送它)而不是移动它。要移动动态对象,请使用 AddForce / Velocity 矢量。
速度示例:
float speed = 2.0f;
Rigidbody2D rb;
rb = GetComponent<Rigidbody2D>();
rb.velocity += new Vector2(speed * Time.deltaTime, 0f);
rb.velocity += new Vector2(速度 * Time.deltaTime, 0f);
0f是玩家位置的Y轴
在相对较高的速度下,碰撞中的角色进入BoxCollider和RigidBody2D内部
尝试将 RigidBody
的 Collision Detection
设置为 Continuous
。
Unity 中的变换移动对象(传送它)而不是移动它。要移动动态对象,请使用 AddForce / Velocity 矢量。
速度示例:
float speed = 2.0f;
Rigidbody2D rb;
rb = GetComponent<Rigidbody2D>();
rb.velocity += new Vector2(speed * Time.deltaTime, 0f);
rb.velocity += new Vector2(速度 * Time.deltaTime, 0f);
0f是玩家位置的Y轴