Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | edwardjoe214 |
extends Node3D
var Room = preload(“res://scene/newScene/newRoom.tscn”)
var tiles = 40
var number_room = 50
var mins = 5
var maxs = 12
func _ready():
randomize()
create_rooms()
func create_rooms():
for i in range(number_room):
var post = Vector3(1,1,1)
var r = Room.instantiate()
var x1 = mins + randi() % (maxs-mins)
var z1 = mins + randi() % (maxs-mins)
r.create_room(post, Vector3(x1, 1, z1) * tiles)
$Room.add_child(r)
in different scene theres :
extends RigidBody3D
var size = Vector3()
func create_room(apos, asize):
position = apos
size = asize
var s = BoxMesh.new()
s.size = Vector3(size)
$CollisionShape3D.shape = s
error, Cannot call method ‘add_child’ on a null value.
how do i fix this
‘’$Room’’ doesnt exist your either freeded it or didnt add to your scene
horsecar123 | 2023-05-07 20:40