Character won't bounce away, please help.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RequiemByte

I have a character that i want to bounce away in the opposite direction its colliding with the enemy in. However when the character collides it only bounes upwards ignoring the x velocity I’m trying to add.

func hit(var enemy_pos):

velocity.y = jumpHeight

Input.action_release("left")
Input.action_release("right")

if position.x < enemy_pos:
	print("less")
	velocity.x = -speed * 2
else:
	print("More")
	velocity.x = speed * 2
	

I’m using an Area2D for the colliding object, and the character is a kinematicbody2D

it accurately identifies position of the object relative to the character