0 votes

Hi, first of all I'm sorry I'm asking so many questions, I will re-pay when I'll be more expert and able to aswer some questions myself (or supporting the engine on patreon). I want to make my player to shoot fireballs.

My fireball script:

    extends Area2D

const SPEED = 2
var velocity = Vector2()

func _ready():
    pass

func _physics_process(delta):
    velocity.x = SPEED + delta
    translate(velocity)
    $AnimatedSprite.play("shoot")


func _on_VisibilityNotifier2D_screen_exited():
    queue_free()

And I've added that to my player script:

const fireballl = preload("res://Fireballl.tscn")

...

if Input.is_action_just_pressed("ui_focus_next"):
        var fireball = fireballl.instance()   #ERROR HERE
        get_parent().add_child(fireball)
        fireball.position = $Position2D.global_position

Then I've added a "position 2d" to the player, so I could set the start position of the fireball from the player

The error is: " Invalid call. Nonexistent function 'istance' in base 'PackedScene' "

in Engine by (55 points)
edited by

2 Answers

+1 vote
Best answer

That should be instance() not istance() (note, you're missing an n)

by (12,286 points)
selected by

Thanks! I will add some info for who want to do the same, so this post won't be that useless :/

0 votes

fireballl constant that you made should be an onready variable like this

onready var fireballl = preload("res://Fireballl.tscn")

by (26 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.