![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Kanor |
I am trying to make a level transition script similar to metroid. It creates a scene, runs the transition, and then deletes the old scene. This is the code so far:
enum DIRECTION { Up, Down, Left, Right }
export(DIRECTION) var direc
export(PackedScene) var scene_to
func _on_Area2D_body_entered(body):
if body.is_in_group("player"):
var player = body
# Create scene
var newScene = scene_to.instance()
# PROBLEM! Move scene to a position relative to existing scene
# Remove player from old scene
owner.remove_child(player)
# Add player to new scene
# Move player into scene
# Destroy this scene. Goodbye self!
My goal is to make it so the editor only has to say the direction the new scene will be placed in, and the new scene will be spawned there. If I wanted to make a door in the LEFT direction, I’ll have to move the new scene to oldscene.position.x
minus the size (width) of my new scene. How do I do that?
My scenes rely heavily on tilesets, and are made to not use death-traps. This means entire scenes are bounded completely by the main tileset. I believe I could finagle a solution through that.