I'm trying to transfer data from one scene to another for a simple modal pop up. I'm using a sensor to sense if the player passes an area (Using a node with a collisionShape2D) and then updating a variable(named Collision) cross nodes to make the "Modal" appear. When I try to update the variable, I get this error "Invalid get index 'collision' (on base: 'String')"
Collision Detector Code
extends Node2D
var collision: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func transerData(old, new):
new.collision = old.collision
func _on_area_2d_body_entered(_body):
$Sprite2D.visible = false
collision = 1
transerData("res://Area2d.tscn", "res://Modal.tscn")
The Modal Code
extends Node2D
var collision: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
$Sprite2D.visible = false # Replace with function body.
position = Vector2(617, 313)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if(collision == 1):
$Sprite2D.visible = true
func transerData(old, new):
new.collision = old.collision
Note: When I hover over the variables it shows the correct values, though the modal also does not set Sprite2D's visibility to true. ???