Attention | Topic was automatically imported from the old Question2Answer platform. | |
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