I am trying to implement a knockback feature, everything seems right, but an error message pops up for the third line of this code from Player.gd:
func knockback(var enemypos):
velocity.y = min_jump_velocity
if position.x > enemypos:
velocity = 800
elif position.x < enemypos:
velocity = -800
Over in Enemy.gd I have:
func _on_Hitbox_body_entered(body):
if body.name == "Player":
body.knockback(position.x)
Not really sure why I'm getting an invalid operand call here. Still fairly new to Godot and programming in general.
I tried using enemypos.x, but that presents an "Invalid get index 'x' (on base: 'float')" error.
Any help is appreciated! Thank you.
(haven't been able to mess around with this code to see how 800 works...lol)