0 votes

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

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.