if (bodyCollider.IsTouchingLayers(LayerMask.GetMask(“enemies”)))
{
myAnimator.SetTrigger("Dying");
isAlive = false;
SpriteRenderer mySpriteRenderer = GetComponent<SpriteRenderer>();
mySpriteRenderer.color = Color.red;
myRigidbody.velocity = new Vector2 (-(Mathf.Sign(transform.localScale.x)*10f),3f);
}
it worked great and as intended, when the enemy hits me (whether while walking or idling) it throws the player in the opposite direction and changes it’s color to red. the only problem is if the enemy hits the player from behind, it still throws him but only a small amount for some reason. is there a way to fix that?
thank you