i am try to make the player shot a projectile but if he shoot and jump later the bullet will rise with him(it because the bullet is child to player i did that becuse i can't manage to get the bullet at the same position ) here's the code:
#bullet
extends KinematicBody2D
var velocity = Vector2(0,0)
var SPEED = 10.0
func _physics_process(delta):
if Input.is_action_pressed("shoot"):
velocity.x = SPEED
move_and_collide(velocity)
#player
extends KinematicBody2D
var velocity = Vector2.ZER
const SPEED = 250.0
const GRAVITY = 100.0
const JUMPFORCE = -1500.0
func _physics_process(delta):
velocity.y += GRAVITY
if Input.is_action_pressed("right"):
velocity.x = SPEED
if Input.is_action_pressed("left"):
velocity.x = -SPEED
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMPFORCE
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0.0,0.3)