The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

in my game I run this code on the player

func physicsprocess(delta: float) -> void:
if Input.isactionjustpressed("attack"):
var magic = spell.instance()

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 physicsprocess(delta: float) -> void:

func onTimertimeout() -> void:

but whenever my player moves so does my projectile
how do I fix it

Godot version 3.3.2
in Engine by (34 points)

1 Answer

0 votes


Try to attach your spell's instance to the root of your scene instead of the parent.

I hope this help.

by (21 points)

ummm how do I do that

Try this: get_tree().get_current_scene().add_child(spell_instance)

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 Frequently asked questions and 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 [email protected] with your username.