game not working correctly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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)
`enter image description here

:bust_in_silhouette: Reply From: SnapCracklins

I am seeing a few syntax errors, small fudges like this can cost you in code. For instance, linearvelocity should be linear_velocity as this is a method. It also needs to be rand_range, not randrange or else your methods won’t work. Go back and check your syntax and you might find the solution simpler than you think but this could be the forum auto-formatting your text.

Tip: Click the brackets up top { } and then paste your code in to make it easier for others to read as it will print formatted as code like it does in the editor.

late comment but i dont see thoose errors also i did the bracket thing and pasted the code on where it says it to but it didnt work everything just seems to be working fine except the player isnt on screen/not spawning properly

nukzhy | 2022-04-30 10:51