Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | AshTeriyaki |
I’m a little confused about how to get contents from a PackedScene. I have a script that fires projectile weapons:
export (PackedScene) var Bullet
export (float) var gun_cooldown
var velocity = Vector2()
var can_shoot = true
func _ready():
$GunTimer.wait_time = gun_cooldown
Currently the rate of fire is determined by gun_cooldown
, the script attached to the scene assigned to Bullet
has export (float) var rate_of_fire
which I’d like to use instead.
No idea how I go about accessing this, I’m aware that PackedScene comes with a dictionary, but taking a look through it and I can’t seem to get the value of rate_of_fire
Can anyone point me in the right direction?
Think of a loaded packed scene resource as a class, it does not have anything and needs to be instanced to get an object with properties, like shown in kidscancode’s answer.
eons | 2018-06-12 02:40