Topic was automatically imported from the old Question2Answer platform.
Asked By
Rayu
I want to add a function where when the Player is pressed that the Player stops for 1 sec and it doesn’t add any scores, like it freezes totally for 1 sec.
error: Invalid call. Nonexistent function ‘stop’ in base ‘PackedScene’.
A little help for your error there. You probably need to either instantiate the Player1 variable, or you need to instantiate it in-line. An example of this is:
onready var Player1 = preload("res://Player/Player1.tscn").instance()
Or do something like this:
var player_instance
_ready():
# Use this in the "_on_player1_pressed()" function.
player_instance = Player1.instance()
Hope this helps.
Invalid call. Nonexistent function ‘stop’ in base ‘RigidBody2D (Player1.gd)’
i searched up in the docs for the RigidBody2D did some shenanigan with the sleep and can_sleep properties but failed (again)
And when i do this
onready var Player1 = preload("res://Player/Player1.tscn").instance()
Invalid call. Nonexistent function ‘instance’ in base ‘RigidBody2D (Player1.gd)’
func spawn_player1(num):
for i1 in range(num):
var p1 = Player1.instance() <------------ error
p1.connect("player1_pressed", self, "_on_player1_pressed")
player_container1.add_child(p1)
i just realized, maybe it has something to do with this:
func spawn_player1(num):
for i1 in range(num):
var p1 = Player1.instance()
p1.connect("player1_pressed", self, "_on_player1_pressed")
player_container1.add_child(p1)