Hello! I am facing another issue.
I am making a top-down camera sort of game in which enemies go towards the player. However, after creating the knockback mechanic I quickly found out that the enemy didn't actually recieve any knockback. I am unsure on how to fix this so I hope someone more experienced than myself could help me solve this.
This is the code in character.gd (all characters can take knockback):
func take_damage(dam: int, dir: Vector2, force: int) -> void:
hp -= dam
velocity += dir * force
This is the code that makes the players weapon have a hitbox:
onready var dicesword_hitbox: Area2D = get_node("Dicesword/Node2D/AnimatedSprite/Hitbox")
This is the code that ads a knockback direction to the knockback:
func _process(_delta: float) -> void:
dicesword.rotation = mouse_direction.angle()
dicesword_hitbox.knockback_direction = mouse_direction
And this is the code from the enemy itself:
func _init() -> void:
func _ready() -> void:
if state == states.chase:
func _get_transition() -> int:
if not animation_player.is_playing():
func _enter_state(_previous_state: int, new_state: int) -> void:
Please send help.