optimization physics

MArS_03MArS_03 Posts: 2Member
edited January 2017 in General Chat

I tested physics on Godot. and the result is 30 FPS at 150 bodies and 6 (!) at 200 FPS bodies. Then I tested Box2d physics and there is 30 FPS at 800 bodies. So I asked my programmer put Box2d in Godot, but when he opened the source code he said, "Oh no." Maybe somebody knows how to do this or have other suggestions. For us, a large number of bodies is critical - in the game a lot of enemies + bullet (actually at one time up to 20 enemies + bullets. 20+ bodies is not a lot but
but when they were applied to the impulse it increases the load) and need space for rendering graphics.


Tags :


  • RossRoss Posts: 199Member

    Not sure what there is to say, Godot is slow in general. 800 nodes just sitting there doing nothing will have a noticeable performance cost.

    I made some fairly complex enemies that used a few raycasts every frame to navigate. I couldn't have more than 7 or 8 onscreen at once (with graphics) before the framerate dropped too low. With the same code in blueprint in Unreal, I could have at least 20, and that was with more demanding rendering.

  • MArS_03MArS_03 Posts: 2Member

    frist problem with physics was: with good impulse (by blast or smthg) body can go between two tiles of wall. So a made walls with large solid collision and with large solid texture. but large textures drop performance a lot, then i made texture 2 times less size and scale 2 times more in godot and this helps:D But still using tiles is better for render anyway.

  • razvanc-rrazvanc-r Posts: 84Member
    edited January 2017

    Really? Is it that slow? Note that if you run the game from the editor its performance is completely different than running an exported project. Also about the 800 nodes, I was really curious so I tried. Here's the result:

    Is that noticeable performance cost? Don't know. All 800 nodes are RigidBody

  • _807__807_ Posts: 59Member
    edited March 2017

    Hi, sorry for the english, I don´t think Godot physics are slow, Godot render maybe, I never have "Physics" problem. A bit of tips:

    Every kind of object have their own layer, (Example: Character: layer 1, Bullet: layer 2, Enemy: layer 3....)

    A phisics object that doesn´t collide with itself do not have to "mask" itself: Example : Character is layer 1, Character masks layer 2 (bullet) and layer 3( enemy)... bullets probably doesn´t mask any object, cause probably doesn´t have gamecode and can be accesed by "body" or "area" collision in character to destroy in collision....
    If needed more performance collisions (in terms of cpu cycles) use "area_enter" (body or area), it will skip very fast movement, but are a lot performance.

    Change "Cell size" parameter in options.

    Delete any phisic´s object that end his function (Ej: areas that complete statements in object at "_ready" but doesn´t have functionality in "runtime".

    My game have more that 2000 nodes in every level, one of the levels have more that 10.000 nodes. Problem that i have is with "draw calls" and with "charge times", but not with physics, never have more that 800 collisions pairs and any of the objects have their own "area". Don´t abuse from kinematics, I think that it can be the problem, your bullets should be areas and not have any mask bit toggled true.

Sign In or Register to comment.