User:Senka/a bas nije da nas nikad nije bilo/Godot Debugging
Debugging
Portals
There's a documentation page for portals and rooms [1] but it's outdated (made for Godot 3.5, I'm using 4.3).
Portals to different rooms This needs a lot of reorganizing of the code for it to work... Currently stuck at trying to delete one room once there has been a switch from another (queue_free function not working).
The script is supposed to instantiate a new scene once the body ("Player") enters the portal. After the player has entered the new scene, the previous one is supposed to be deleted with the queue_free function.
Currently I have:
- A portal (Area3D) with the script:
extends Area3D var next_scene = preload("res://rooms/room_2.tscn") var current_scene = preload("res://rooms/room_1.tscn") func _on_body_entered(body: Node3D) -> void: if body.name == "Player": if body.in_transition == false: body.in_transition = true print("something might work") var instanced_scene = next_scene.instantiate() get_tree().root.get_node("World").add_child(instanced_scene) func _on_body_exited(body: Node3D) -> void: if body.in_transition: body.in_transition = false
- room2 (Node3D) with the script:
extends Node3D @onready var player = $Player @onready var room1 = "res://rooms/room_1.tscn" # Called when the node enters the scene tree for the first time. func _ready() -> void: player.camera.make_current()
- the World (root) node (Node3D):
extends Node3D @onready var room1 = "res://rooms/room_1.tscn" var room1_scene = preload("res://rooms/room_1.tscn") # Called when the node enters the scene tree for the first time. func _ready() -> void: if room1_scene != null and is_instance_valid(room1): #room1.queue_free() var deletion_scene = room1_scene.instantiate() deletion_scene.queue_free() print("room1 deleted")
No error appears with this version of the code but it doesn't work.
Question:
- How to adjust the code to delete the previous room? (While allowing the user to enter back)
FIXED WITH adding:
get_tree().root.get_node("World/room1").free()
This fixes it because what I was doing before, calling a variable in the queue_free() function, wasn't working and was giving it a null value
Next steps:
- Why is the portal in the new scene not appearing?
error code: W 0:00:25:0044 portal.gd:17 @ _on_body_entered(): Node './Portal' was modified from inside an instance, but it has vanished. <C++ Source> scene/resources/packed_scene.cpp:254 @ instantiate() <Stack Trace> portal.gd:17 @ _on_body_entered()
The instantiated scene does not appear in the HTML exported version. There are the errors that pop up:
- How to do this code in the World script instead of the Portal script?
question for thijs, but only if you have time!
- Can portals refer to/lead to HTML pages? (I would love to link some rooms to bitsy pages if possible)
question for thijs
HTML/itch.io Exporting
Questions:
- If the game is uploaded as an html page, is it better to have the menu as javascript button on top of the game (canvas item) or to have an in-game menu? Would the in-game menu access the in-game mechanism better? (Such as room change)
question for thijs
- Creating subdomains for your website?
How to improve loading?
Rich Text Label
Texture
Fixed:
- All texture issues can be solved with importing glft/glb instead of a blend file
- light from blender need to be 50mW or less