Game Development Community

Problems with high velocity

by Michael McCarthy · in Torque 2D Beginner · 02/18/2014 (6:24 pm) · 3 replies

I'm having difficulty getting my CompositeSprite objects to move at high velocities. I am using the setLinearVelocity() function (and have also tried setLinearVelocityPolar(), and setLinearVelocityX() & setLinearVelocityY() ) but it seems like the objects won't go any faster than about 130. In my scene this appears to be fairly slow, especially since I will have fast moving bullets in the game.

My scene width and height are 1280x960, which doesn't seem too large of a game screen to me.

Is there some sort of built in maximum-velocity that objects can reach? Is there a way to raise that limit?

About the author

Recent Threads

  • XBox controller input

  • #1
    02/18/2014 (8:26 pm)
    You can change the number of iterations the physics engine goes through, which might impact performance. How to do so is described in this chapter of the Physics guide.

    Or

    You can set your high-velocity objects to be treated as bullets as described here

    #2
    02/18/2014 (9:11 pm)
    What is the size of your camera view? Is it also 1280x960? If yes, then that is too big. This is described in the physics guide as well:

    Quote:"Box2D works with floating point numbers and tolerances have to be used to make Box2D perform well. These tolerances have been tuned to work well with meters-kilogram-second (MKS) units. In particular, Box2D has been tuned to work well with moving shapes between 0.1 and 10 meters. So this means objects between soup cans and buses in size should work well. Static shapes may be up to 50 meters long without trouble."

    The physics size on the screen is dependent upon the view size of the camera. If you are having trouble understanding that and create your objects so that each pixel on the screen displays a single world unit then don't be surprised if dynamic rigid-body objects don't respond correctly. This completely down to Box2D and not Torque 2D but Box2D has good reasons for this. If your object is 500x500 world-units in size then the object is 500 metre x 500 metre in size which is huge! Whilst the effects of such large objects is minimal for static objects, dynamic objects can suffer from both accuracy problems as well as the need to apply huge forces to make them move.

    This is why in the example modules included with T2D the camera view size is typically 100 x 75.
    #3
    02/21/2014 (4:00 pm)
    Thank you. It was the camera size. I didn't realize the difference in World Space vs. pixels.

    Thanks a lot!