I'm making a 2D game in which one of the bosses jumps to a fixed height.
Example:
const GRAVITY = 900
const JUMP_STR = -350
var jump = false
var jump_delay = 60
var velocity = Vector2.ZERO
func _physics_process(delta):
if is_on_floor():
jump _delay -= 1
if jump_delay == 0:
#velocity.x = (THIS IS WHERE I'M HAVING TROUBLE.) <===
velocity.y = JUMP_STR
jump = true
velocity.y += GRAVITY * delta
velocity = move_and_slide(velocity, Vector2(0, -1))
What I'm wanting to do is calculate velocity.x to make the boss attempt to land on the player's x position which is calculated when the boss jumps. Unfortunately, I haven't the foggiest idea on how to do this. Please help.