Hi there, completely new to godot, taking my first babysteps. I've done development in unity before and have to unlearn a few things. Recreated the tutorial game squash the creeps so I'm not totally clueless
Just made a simple little test of a 3d plane with a player square, a house, a way to enter, a second scene with the house interior and a way to exit.
I load up the main scene (my "outside") and preload the inside of the house
I can enter the house by being inside an area3d in front of it (i switch a bool upon entering the are) and hitting enter
Once inside i can exit via the same system
But once I'm outside again, my camera tracking does no longer work and my "enter" events are not heard any longer. I'm not sure whats going on here, is the main script not loaded? what could be the cause of this? Am I missing a checkmark somewhere?
Probably a very easy beginner mistake, But I'm so new to the menus..
My code for the main scene:
extends Node3D
var houseinside = preload("res://Insidehouse.tscn").instantiate()
var someoneAtTheDoor = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
$CameraPivot.look_at($Player.position)
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and someoneAtTheDoor:
# This restarts the current scene.
enterHouse()
func enterHouse():
print_debug("Entering House")
get_tree().root.add_child(houseinside)
someoneAtTheDoor = false
queue_free()
func _on_house_someone_at_the_door():
someoneAtTheDoor = true
func _on_house_someone_left_the_door():
someoneAtTheDoor = false
code for the house object:
extends StaticBody3D
signal someoneAtTheDoor
signal someoneLeftTheDoor
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func someoneIsAtTheDoor():
someoneAtTheDoor.emit()
$EnterText.visible = true
func _on_door_area_body_entered(body):
someoneIsAtTheDoor()
print_debug("entered")
func _on_door_area_body_exited(body):
print_debug("left")
someoneLeftTheDoor.emit()
$EnterText.visible = false
and for the inside of the house:
extends Node3D
var outside = preload("res://main.tscn").instantiate()
var someoneAtTheDoor = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and someoneAtTheDoor:
# This restarts the current scene.
enterHouse()
func enterHouse():
# This is like autoloading the scene, only
# it happens after already loading the main scene.
get_tree().root.add_child(outside)
someoneAtTheDoor = false
queue_free()
func _on_door_area_body_entered(body):
someoneAtTheDoor = true
print_debug("entered")
$LeaveText.visible = true
func _on_door_area_body_exited(body):
someoneAtTheDoor = false
print_debug("left")
$LeaveText.visible = false
edit: also, if there is a better way for screne transition, I'd be happy to hear it!