func _physics_process(delta):
if Input.is_action_just_pressed(“attack”):
var Player = load(“res://Player/Player.tscn”)
var GreenBullet = load(“res://Bullets/GreenBullet.tscn”)
var greenBullet = GreenBullet.instance
greenBullet.x = Player.x
greenBullet.y = Player.y
var collision = move_and_collide(velocity * delta)
if collision != null:
queue_free()
so im newer to the engine, but I can see what’s wrong.
greenbullet.x = player.x and greenbullet.y = player.y means that you’re teleporting the sprite over to the player, at least thats what I think.
what I would do (I dont know gdscript so well, I do python but you can probably figure out what I mean) is this:
if greenBullet.x > player.x:
greenBullet.x + 10 (or 20 or however many pixels you want) elif greenBullet.x < player.x:
greenBullet.x - 10 (or 20 or however many pixels you want). else:
greenBullet.x = greenBullet.x
do the same thing but replace x with y, and maybe that might work. not trying it out in Godot myself, but yeah.