简体   繁体   English

JBox2D碰撞不反弹

[英]JBox2D collisions not bouncing

I have an Android application using JBox2D for physics simulation. 我有一个使用JBox2D进行物理模拟的Android应用程序。 The only dynamic object is a 0.07m radius circle, as well as several static circles and rectangles in a total game area of about 20m by 20m. 唯一的动态对象是半径为0.07m的圆,以及整个游戏区域中约20m x 20m的几个静态圆和矩形。 I'm also using a few custom forces through the ApplyForce method. 我还通过ApplyForce方法使用了一些自定义作用力。

Whenever any bodies collide, they do collide correctly however they don't bounce; 每当任何物体碰撞时,它们都会正确碰撞,但不会反弹。 everything just thuds together. 一切都在一起。 All bodies have their densities, frictions and restitutions set (some objects have a restitution greater than 1). 设置了所有物体的密度,摩擦和恢复力(某些物体的恢复力大于1)。

Does anyone have any ideas why these collisions aren't working? 有谁知道为什么这些冲突不起作用? I think it might be because the bodies aren't moving fast enough for JBox2D to count as proper collisions (there is a cutoff in Box2D). 我认为可能是因为这些实体的移动速度不够快,JBox2D不能算作适当的碰撞(Box2D中存在中断)。

Thanks! 谢谢!

setting Settings.velocityThreshold = 0.0001f; 设置Settings.velocityThreshold = 0.0001f; (or very small) solved it for me. (或很小)为我解决了。

我发现了部分解决方案-如果速度低于某个阈值,Box2D(至少是JBox2D)会忽略恢复原状-通过将我的所有对象放大10倍,阈值变得相对较低,对象反弹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM