I took the center of the box as its corner. I want to take the corner coordinates as (0,0,0). However, the corner appears at x= 90 and z= 90 coordinates. Where am I going wrong? What code should I write to fix this? or something else
extends Node3D
var boxes = []
var boxTemplate = preload("res://boxTemplate.tscn")
func create_box(location, scale, layer, color):
return { "location": location, "scale": scale, "layer": layer, "color": color }
func create_boxes():
var rows = 13
var columns = 13
var x = 0
var z = 0
var l = 0
var layers = 3
var colors = [Color(1, 0, 0), Color(0, 0, 1), Color(0, 1, 0)] # Kırmızı, Mavi, Yeşil
boxes.append(create_box(Vector3(x- 90 , l, z + 90), Vector3(5, 4, 10), 1, colors[1])) func create_visual_box(location, scale, color):
var box = boxTemplate.instantiate() as Node3D
var mesh_instance = box.get_child(0) as MeshInstance3D # MeshInstance3D'yi al
var mesh = BoxMesh.new()
mesh.size = scale / 200
mesh_instance.mesh = mesh # MeshInstance3D'ye mesh'i ata
box.transform.origin = location / 200
var material = StandardMaterial3D.new()
material.albedo_color = color
mesh_instance.material_override = material # MeshInstance3D'ye material'ı ata
add_child(box)
func _ready():
create_boxes()
for box in boxes:
create_visual_box(box["location"], box["scale"], box["color"])
print("Box at %s on layer %d with color %s" % [str(box["location"]), box["layer"], str(box["color"])])
print("--- Tüm katmanlar bitti ---")