CannonJS在”东”向墙面上存在大摩擦力(粘滞),同时摩擦力系数为0。

huangapple go评论56阅读模式
英文:

CannonJS Massive friction (sticky) on "east" facing walls while having a 0 friction

问题

目前在我的游戏中,我有一个角色,其碰撞箱是由球体构成,摩擦力为0。

在移动到墙壁时,一切都按预期顺利进行(我设置了角色的速度)。

除非墙壁朝着我的游戏中的“东方”(-x轴方向)。

我尝试过的事情:

我放置了一个动态立方体,我可以推动它,如果我试图从3个面推动它,我会沿着它们滑动(这是预期的),但是朝向-x方向的面我的角色不会沿着墙壁滑动,只是简单地粘在上面,我必须后退才能移动。

这里情况变得奇怪,如果我推动立方体以使其旋转,先前粘性的一侧现在变得光滑和完美,现在新的朝向-x(东)方向的面现在变得粘性。

我还尝试过使用其他作者创建的地图,但出奇地发生了相同的事情。

此处是一个示例视频 ,显示了我推动一个立方体的情况,在3个工作的侧面推动并被卡在-x轴面上。然后我推动立方体,使粘性的一侧现在朝向不同的轴,它就可以工作了,而现在另一侧变得粘性。

英文:

Currently in my game, I have a character with spheres as its collision box with 0 friction.

When moving into walls everything works smoothly as intended (I'm setting the character body's velocity)

UNLESS the wall is facing "east" in my game (-x axis direction)

Things i've tried:

I've placed a dynamic cube, that I can push around and if I try and push it from 3 of the faces i slide along them (intended) but the -x direction facing face my character wont slide along the wall, just simply sticks to it and I would have to back up in order to move.

here's where it gets strange, if I push the cube so that it rotates, the side that was previously sticky, now is smooth and perfect again, and the now new face that faces -x (east) direction is now sticky.

I've also tried using maps from other creators and for some reason the same thing happens.

https://youtu.be/f8Ku_ovWzf0 Youtube link example of me pushing a cube on 3 of working sides, and getting stuck on the -x axis face. I then push the cube so that the sticky side is now facing a different axis and it works, and a different face is now sticky

答案1

得分: 1

我已解决了这个问题,问题出在CannonJS上,我根据SAPBroadphase对物体进行排序。这会默认按x轴排序物理效果。这会导致我的玩家(在物理世界中)首先被模拟,然后与其碰撞的物体,导致它粘在上面,而不是滑动。

解决方法是将玩家排在最后模拟的物体之后。

英文:

I have solved the problem, The problem was with CannonJS i was sorting things based on SAPBroadphase. This will order the physics based on the x-axis by default. This would cause my player (in the physics world) to be simulated first, THEN the object it collides with causing it to stick, rather than slide.

The fix was to order the player to be the last simulated object.

huangapple
  • 本文由 发表于 2023年6月1日 03:14:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定