Godot Version
4.3
### Question
I have a for loop looping around 64 chess tile pieces with automatic transparency animations but the only problem is if I load another tile, all the tiles flicker. And I can’t find anyone asking a similar question.
My code is below but since this is a visual error I’ve also linked a Youtube video of my problem.
LINK:
https://youtu.be/J7eQEyDbJm8
CODE:
( HERE IS MY CODE IN A EMPTY NODE 3D THAT ADDS THE TILES)
extends Node3D
Preload the white and black tile scenes
var white_tile_path = preload(“res://scenes/piece_scenes/white_pieces/white_tile.tscn”)
var black_tile_path = preload(“res://scenes/piece_scenes/black_pieces/black_tile.tscn”)
Called when the node enters the scene tree for the first time
func _ready() → void:
# Wait for 1 second before starting the board creation
await get_tree().create_timer(1).timeout
var row = 0 # Tracks the current row on the chessboard
# Loop through tiles from 1 to 64 to create an 8x8 grid
for tile in range(1, 65):
# Small delay for visual effect while generating the board
await get_tree().create_timer(0.1).timeout
var tile_color # Will hold the color of the tile to instantiate
# Determine the tile color based on row and tile number
if row % 2 == 0: # Even row
if tile % 2 == 0:
tile_color = black_tile_path # Even tile on even row is black
else:
tile_color = white_tile_path # Odd tile on even row is white
else: # Odd row
if tile % 2 == 1:
tile_color = black_tile_path # Odd tile on odd row is black
else:
tile_color = white_tile_path # Even tile on odd row is white
# Instantiate the selected tile scene
var instantiated_tile = tile_color.instantiate()
# Calculate the x and z positions for the tile on the chessboard
var x = (-3.5 + (tile % 8 if tile != 0 else 0))
var z = -3.5 + row
print(x, row) # Debug print to check positions
# Set the tile's position and add it to the scene
instantiated_tile.position = Vector3(x, 0.8, z)
add_child(instantiated_tile)
# Move to the next row after every 8 tiles
if tile % 8 == 0 and tile != 0:
row += 1