::Hi Logique, thanks for dropping in to the stream just now. If I had known your question was simple I would’ve answered it in the stream. My bad.
The pushing is not caused by damage knockback. It is caused because both the enemies and the player have a solid collider. You need to disable the solid collider on the player by checking its Is Trigger attribute, but this will cause the enemy to be unable to damage the player, because the damage only happens on a collision.
To restore enemies damaging the player, you need to the following to EnemyStats.cs
to get triggers to register damage:
void OnTriggerStay2D(Collider2D col)
{
//Reference the script from the collided collider and deal damage using TakeDamage()
if (col.gameObject.CompareTag("Player"))
{
PlayerStats player = col.gameObject.GetComponen<PlayerStats>();
player.TakeDamage(currentDamage); // Make sure to use currentDamage instead of weaponData.Damage in case any damage multipliers in the future
}
}
Hope this makes sense!