0 votes

Hi all,

I am building a simple demo made of 2 scenes:

  • main scene containing the floors
  • cube scene

Upon loading the main scene, i am generating some cubes at random position.

collision code snippet:

_ready(): 
...
set_physics_process( true )
set_max_contacts_reported( 1 )

And

_physics_process(delta):
    var bodies = get_colliding_bodies()

    for curBody in bodies:
        print( "collision :" + curBody.get_name() )

I am getting lots of prints and collisions, however:

  • Is this the correct way / "best performance" way of detecting collision in 3D ? I am asking this, cause having a simple scene with 40 cubes, makes the game "choke" for like 2 seconds.
  • Some collisions seems to pass undetected (even though CCD is enabled).

Btw, I am using Godot 3.0.5

asked Jul 23, 2018 in Engine by GameVisitor (814 points)

Did you leave your print during the 40 cubes test? Printing is an expensive operation, so it should not be used to logspam.
Also, collisions can go undetected because you did set_max_contacts_reported( 1 ).

1 Answer

0 votes
Best answer

I did solve it, i was changing the cubes texture upon hitting certain body and the texture was being null, probably similar to throwing an exception and rendering it white. Once the correct texture was set the 2 seconds delay disappeared.

I also did turn off print statements in 2 _physics_process() of the game, prior to your suggestion and that gained me around 3 FPS.

As for your final suggestion, I think you are right, but what is the recommended value here ? surely setting it too high will have a strong performance impact, no ?

Thanks for your time @Zylann :-)

answered Jul 23, 2018 by GameVisitor (814 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.