Boostgb
Boostgb

Reputation: 7

I am trying to make a tile layer be disabled in code Godot

This is my current code:

extends TileMap

signal button1_1

func _on_activate_buton_body_entered(_body):
    button1_1.emit()
    

I want it to disable a door 1 layer in the tilemap when the on_activate_button function is triggered

i tried using chat gpt and i tried using the tilemap and .layers.Door1.enabled = false

Upvotes: 1

Views: 957

Answers (1)

Theraot
Theraot

Reputation: 40345

A look in the documentation for TileMap and reading the list of methods, should take you to set_layer_enabled:

void set_layer_enabled ( int layer, bool enabled )

Enables or disables the layer layer. A disabled layer is not processed at all (no rendering, no physics, etc...).

If layer is negative, the layers are accessed from the last one.

We, of course, do not want to enable the layer, so we are going to pass false on the enable parameter.

Thus, you would disable a layer like this:

set_layer_enabled(layer_number, false)

For example, disabling the layer 1 would be:

set_layer_enabled(1, false)

Upvotes: 0

Related Questions