This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Tree:
This is my tree  of the node I want to instance

SCRIPT:
Here is my first statement:
Preload the node
Creation of the instances:
Instances
When the user makes a mistake, I match the error number:
In this routine I want to disable the CollisionShape2d and hide th Sprite
When the game stops:
Destroy all instances
When the user wants to replay the game:
re-creation of the instances

My problem is: I am not able to hide the Sprite and disable the CollisionShape2d
I tried setdefered, free, queuefree nothing works.
Can you help me please.
Michel

Godot version v.3.2.3 stable
in Engine by (31 points)

Can You share images in other way ? A lot of antivruses block these

I do not have a webSite. I use DropBox to send images.
Michel

2 Answers

0 votes
$Sprite.visible = false
$Kinematicbody2d/CollisionShap2d.set_deferred("disabled",true)

That always works for me; also sorry if this doesn't answer you're question, the images won't load.

by (663 points)
0 votes

Since the images are not shown here is my data.
Tree: cloture.tscn
cloture (Type: node2D)
|__ k1 (Type: KinematicBody2D)
****|__ brun (Type: CollisionShape2d)
********|___ b1 (Type: Sprite)

SCRIPT: in game.tscn

Here is my first statement:

var barreau1 = preload("res://scenes/cloture.tscn")
var barreau2 = preload("res://scenes/cloture.tscn")

Creation of the instances:

    k1 = barreau1.instance()
    brun1 = k1.get_node("k1/brun")
    b1 = k1.get_node("k1/brun/b1")
    k2 = barreau2.instance()
    brun2 = k2.get_node("k2/brun")

When the user makes a mistake, I match the error number:

    match compteur:
        1: 
            $explosion.start()
            brun1.set_deferred("disabled",true)
            b1.visible = false
            brun2.set_deferred("disabled",true)
            b2.visible = false
        2:
            $explosion.start()
            bleu3.set_deferred("disabled",true)
            b3.visible = false
            bleu4.set_deferred("disabled",true)
            b4.visible = false

In this routine I want to disable the CollisionShape2d and hide th Sprite

I am not able to hide the Sprite and disable the CollisionShape2d
I tried setdefered, free, queuefree nothing works.
Michel

by (31 points)

Please cancel this question. I did solve the problem. Instead of preloading the scene, I instance my scene in the tree of my game.
Thank you Merlin1846. Now it is working fine.
Michel

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.