Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | MightyRat |
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’ "
Shouldn’t velocity.x be “* delta” instead of “+ delta”?
SuperMatCat24 | 2023-02-25 18:05