Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nukzhy |
so i am following this tutorial
things seem to work properly except that the enemies only spawn on one spot and the player seem to not spawn`extends Node
export(PackedScene) var mob_scene
var score
func _ready():
randomize()
new_game()
func _on_Player_hit():
pass
func game_over():
$ScoreTimer.stop()
$MobTimer.stop()
func new_game():
score = 0
$Player.start($StartPosition.position)
print(“hello”)
$StartTimer.start()
print(“hello”)
func _on_StartTimer_timeout():
$MobTimer.start()
$ScoreTimer.start()
func _on_ScoreTimer_timeout():
score += 1
func _on_MobTimer_timeout():
var mob = mob_scene.instance()
var mob_spawn_location = get_node(“MobPath/MobSpawnLocation”)
var direction = mob_spawn_location.rotation + PI / 2
mob.position = mob_spawn_location.position
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
var velocity = Vector2(rand_range(150.0, 250.0), 0.0)
mob.linear_velocity = velocity.rotated(direction)
add_child(mob)
`