![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | bellhwi |
When I press fire key during jumping,
the bullet is instantiated on the air and moving forward for a bit,
but then it goes down.
How can I fix it?
Thank you for any comments!
player code
extends KinematicBody2D
func fire():
var projectile = load("res://Projectile.tscn")
var bullet = projectile.instance()
add_child_below_node(get_tree().get_root().get_node("Stage"), bullet)
bullet code
extends KinematicBody2D
var velocity = Vector2()
const SPEED = 2500
func _ready():
velocity.x = SPEED
func _physics_process(delta):
if position.x > SPEED / 2:
queue_free()
move_and_slide(velocity)