![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Ouch_Bird |
I do not understand what it is trying to tell me.
Error: Invalid call. Nonexistent function ‘instance’ in base ‘Nil’.
0 - res://Main.gd:13 - at function: _on_MobTimer_timeout
extends Node
export (PackedScene) var mob_scene
func _ready():
randomize()
func _on_MobTimer_timeout():
var mob_spawn_location = $MobPath/MobSpawnLocation
mob_spawn_location.unit_offset = randf()
var mob = mob_scene.instance()
add_child(mob)
mob.position = mob_spawn_location.position
var direction = mob_spawn_location.rotation + PI / 2
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = velocity.rotated(direction)