Hi, I code in GDScript.
I've been trying to instantiate pickups into my game to make the level making process alot easier, but the pickups won't show up, and when they do, I then can't use them. I will put my code below for anyone to check, but I'm pretty confused, as I haven't struggled with instantiating before.
CODE
var ppus = preload("res://Peanut pickup.tscn")
func _ready():
var ppus_instance = ppu.instance()
ppus_instance.position = $Peanut_pickup_spawn1.get_global_position() #the $Peanut_pickup_spawn1 node is a child
node of the player.
ppus_instance.rotation_degrees = 0
get_tree().get_root().call_deferred("add_child", ppus_instance)
And then the code for the pickup that I am trying to instantiate:
extends Area2D
var player_inside = false
signal peanut_picked_up
func _ready():
show()
func _physics_process(delta):
if Input.is_action_pressed("pickup"):
if player_inside:
emit_signal("peanut_picked_up")
hide()
queue_free()
else:
pass
else:
inside_check()
func _on_Peanut_Pickup_area_entered(area):
player_inside = true
$AnimationPlayer.play("on player entered")
Any suggestions would be greatly appreciated. I probably won't get back to you for about a week, as I am going on holiday without my laptop. Sorry and thank you :)