So its only the parts of the code where I need to get arrays for the cards but it just gives me an “identifier level not found in current scope” but in the video the guy does it fine without any issues.
extends Area2D
class_name Card
func _ready():
if level.is_card_collected():
$animationplayer.play("Get")
$CollisionShape2D.set_deffered("disabled", true)
func _on_body_entered(body):
$animationplayer.play("Get")
$CollisionShape2D.set_deffered("disabled", true)
func _on_animation_player_animation_finished(anim_name):
if anim_name == "Get":
level.get_card()
$AnimationPlayer.play("Collected")
##The other code from video
extends Node
const levels = ["Galaxy map"]
var cards: Array = []
func _init():
for l in len(levels):
var level_cards = [false]
cards.append(level_cards)
func get_card():
cards[0][0] = true
func is_card_collected():
return cards[0][0]
The thing you’re missing is at 7:00 in the video: The level.gd script is supposed to be an autoload. You can add this at Project -> Project settings -> Globals -> Autoload
Big thanks. When I load the scene however what ends happening is I walk into the card and the animation doesn’t play. I’m gonna work on the rest of the level just wanted to try and see why this is happening.