Godot Version
4.2
Question
Greetings to all
I wrote this code to repel the enemy when kicking,
func kick_successful(kick_damage):
if kick_damage <= 1:
knockback_vector = enemi.global_position
knockback_vector *= kick_damage * KNOCKBACK_POWER
knockback_vector *= Vector3(1, 0, 1)
knockback_vector = knockback_vector.limit_length(KNOCKBACK_LIMIT)
current_speed = stune_speed
$kick_cd.start()
my question is how to add directions regarding a player’s kick
but how to make it push off in the direction, otherwise now it is not clear where it is pushing off when kicking. I had a working option when adding a player and his location, but I thought that it would not be right in the end when there would be many different enemies, locations, etc.
Well, then I want to add the same thing to the player by analogy
Thanks in advance for your concern
And an additional question in advance is how to make it smooth on the player, not jerky
On a player, it looks something like this
func knockbacking():
var knockback_direction = -igrok.global_position
knockback_direction *= knockback_power
knockback_direction *= Vector3(1, 0, 1)
velocity = knockback_direction
move_and_slide()