func _on_mob_timer_timeout() → void:
print(“mob timer triggered”)
var mob = mob_scene.instantiate()
add_child(mob)
print (“mob instantiated and added”)
# Choose a random location on Path2D.
var mob_spawn_location = $MobPath/MobSpawnLocation
mob_spawn_location.progress_ratio = randf()
# Set the mob's position to a random location.
mob.position = mob_spawn_location.position
# Apply a velocity to the RigidBody2D mob
var velocity = Vector2(100, 0) # Set an initial velocity
var direction = 45.0 * deg_to_rad(1) # Angle in radians (45 degrees)
var rotated_velocity = velocity.rotated(direction)
# Set the mob's linear_velocity (this works for RigidBody2D)
mob.linear_velocity = rotated_velocity
if mob_scene == null:
print("mob_scene is not assigned!")
@export var mob_scene: PackedScene
var score
func game_over():
$MobTimer.stop()
func new_game():
$Player.start($StartPosition.position)
$StartTimer.start()
func _on_start_timer_timeout():
print ("timer good")
$MobTimer.start()
func _on_mob_timer_timeout() -> void:
print("mob timer triggered")
var mob = mob_scene.instantiate()
add_child(mob)
print ("mob instantiated and added")
# Choose a random location on Path2D.
var mob_spawn_location = $MobPath/MobSpawnLocation
mob_spawn_location.progress_ratio = randf()
# Set the mob's position to a random location.
mob.position = mob_spawn_location.position
# Apply a velocity to the RigidBody2D mob
var velocity = Vector2(100, 0) # Set an initial velocity
var direction = 45.0 * deg_to_rad(1) # Angle in radians (45 degrees)
var rotated_velocity = velocity.rotated(direction)
# Set the mob's linear_velocity (this works for RigidBody2D)
mob.linear_velocity = rotated_velocity
if mob_scene == null:
print("mob_scene is not assigned!") ```
Oh! Thank you! I was very confused on why it wasn’t typing the whole thing correctly! And yes, none of the print statements are printing so I’m very confused about where I went wrong.
I would bet your timer’s timeout signal isn’t connected, you can do this through the editor or through code. If you did it through the editor you should see a green symbol by the func _on_start_timer_timeout name.