![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | cobracon |
in my game I run this code on the player
func _physics_process(delta: float) → void:
if Input.is_action_just_pressed(“attack”):
var magic = spell.instance()
get_parent().add_child(magic)
var spell = load(“res://scenes/progectile.tscn”)
and this on my projectile
extends KinematicBody2D
var velocity = Vector2.ZERO
func _ready() → void:
if Global.area == 1:
velocity.y = -190
if Global.area == 2:
velocity.y = 190
if Global.area == 3:
velocity.x = 190
if Global.area == 4:
velocity.x = -190
func _physics_process(delta: float) → void:
move_and_slide(velocity)
func _on_Timer_timeout() → void:
queue_free()
but whenever my player moves so does my projectile
how do I fix it