Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A possible thread conflict. #291

Closed
marcosbitetti opened this issue Apr 15, 2014 · 3 comments
Closed

A possible thread conflict. #291

marcosbitetti opened this issue Apr 15, 2014 · 3 comments

Comments

@marcosbitetti
Copy link

In a scene with a various collision nodes, each node is a instance that call a function in Player node.
My Player collides with two nodes at same time and cause a crashes in the game window and close it, a debugger instance is lose too.

Its issue not occurs in all time, but the little incidence (almost 10%) is worrying.

I hope these info can help.

scene

captura de tela de 2014-04-14 19 10 40

Node Healt

extends Area2D

var taken=false

var player = null
var playerDT = null

var tipo = "healt"
var value = 20

func _on_body_enter( body ):
    if (not taken ): #and body extends player):
        taken=true
        playerDT.incHealt(value)
        get_parent().remove_child(self)

func _ready():
    player = get_node("/root/stage/Player")
    playerDT = get_node("/root/playerdata")
@marcosbitetti
Copy link
Author

Well, some a lot of crashes and tests to I see that it does when a two or more collisions trigger events when I manipulate a scene tree.
When a node is removed, physical server sometimes call a destroyed object, or vice versa.

This appears to solve in GDScript level

func _on_body_enter( body):
    #some code ...
    set_block_signals(true)
    set_contect_monitor(false)
    set_active(false)
    queue_free()
    get_parent().remove_child(self)

And my game running for minutes without crash ^^

@reduz
Copy link
Member

reduz commented Apr 28, 2014

oh, you don't really need to call remove_child(self). when deleted by
queue_free(), the node will be removed too

On Mon, Apr 28, 2014 at 2:06 PM, Marcos Augusto Bitetti <
notifications@github.com> wrote:

Well, some a lot of crashes and tests to I see that it does when a two or
more collisions trigger events when I manipulate a scene tree.
When a node is removed, physical server sometimes call a destroyed object,
or vice versa.

This appears to solve in GDScript level

func _on_body_enter( body):
#some code ...
set_block_signals(true)
set_contect_monitor(false)
set_active(false)
queue_free()
get_parent().remove_child(self)

And my game running for minutes without crash ^^


Reply to this email directly or view it on GitHubhttps://github.com//issues/291#issuecomment-41584809
.

@marcosbitetti
Copy link
Author

Sounds fine to me. Very thanks.
But, apparently queue_free was forgotten in documentation, both in Wiki like in IDE Help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants