Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SilentYapper |
I’m fairly new to Godot so I’m following a tutorial that lots of people recommend. Its by GDQuest (link: https://www.youtube.com/watch?v=WEt2JHEe-do&t=2392s) but it was made in an older version of Godot. I was warned about this but told that the comments would have the updated code. But for this particular instance it does not. The tutorial said to use .instance(), but that command no longer exists. I put in .instantiate() becuase it seemes like the closetest thing and later verified it was right. But it keeps returning “Cannot call method ‘instantiate’ on a null value”. Any idea whats wrong??
Code:
extends Node
@export var mob_scene: PackedScene
func _ready():
randomize()
func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
var mob_spawn_location = $MobPath/MobSpawnLocation
mob_spawn_location.progress_ratio = randf()
mob.position = mob_spawn_location.position
var direction = mob_spawn_location.rotation + PI / 2
direction += randf_range(-PI / 4, PI / 4)
mob.rotaion = direction
var velocity = Vector2(randf_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = velocity.rotated(direction)
add_child(mob)
Error Message:
Did you set a packed scene for your exported scene in your inspector
Venex2004 | 2023-04-25 06:35