Lag and error when adding / freeing nodes

GarromOrcShamanGarromOrcShaman Posts: 166Member

Hi everyone. When area enter area I trying to run this code

if body is Area:
        if body.is_in_group("test_group"):
            var yellow_cube_explosion_instance  = yellow_cube_explosion_scene.instance()
            yellow_cube_explosion_instance.transform.origin = Vector3(body.transform.origin.x,body.transform.origin.y + 1.2,body.transform.origin.z)
            get_tree().current_scene.add_child(yellow_cube_explosion_instance)
            body.queue_free()

Every time it run, game lag a little and in cmd is written :
ERROR: Area::_body_inout: Condition ' !body_in && !E ' is true.
At scene\3d\area.ccp:160

But code finish job normally, one node is removed and one created but only fact that there was error means something went wrong. I tried to google but call_deferred does not help.
Thanks
-Garrom
Tagged:

Tags :

Answers

  • GarromOrcShamanGarromOrcShaman Posts: 166Member
    Answer ✓

    I noticed it happens only when i try to add node. Maybe problem is because i create particle emitter inside area. Within same frame i destroy node with area in it but area still emit signals... Maybe all i must do, is to swap two lines...

  • GarromOrcShamanGarromOrcShaman Posts: 166Member

    I feel stupid... I stuck for 4 days because of order of lines. God damn.

  • MegalomaniakMegalomaniak Posts: 946Admin

    Happens to the best of us.

Sign In or Register to comment.