Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

libgdx - Is there an upper limit on velocity when using box2d?

I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is supposed to. My world's dimensions are 400x800 pixels. The radius of the circle body is 20f.

According to this, the problem can be solved by scaling the circle radius down when creating it and scaling up after getting the body position during painting. It doesn't seem to make any difference at all. Is there some step or setting I'm missing here ?

Code on pastebin

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It took me pretty long to understand that now, but there actually really IS a hard limit on velocity in Box2D. See here:

There is a maximum movement limit of 2.0 units per time step, given in the file b2Settings.h in the source code.

If you have one step per frame at 60FPS, then your bodies can move at a maximum speed of 120m/s. Maybe this will save somebody a bit of time one day.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...