I’m trying to get a wall hitting animation to work for a while now. I want a clash animation to occur right on the spot of the wall the weapon had collided. This is a 2D action platformer.
I am trying to get something like what we see in Hollow Knight, where the clash animation occurs right at the tip of the wall instead of the inside.
I feel like I am missing something here…
I’ve tried the following:
//1
Instantiate(effect, GetComponent<CapsuleCollider2D>().bounds.ClosestPoint(other.GetComponent<TilemapCollider2D>().transform.position), Quaternion.Euler(0, 0, Random.Range(0, 90)));
//2
Instantiate(effect, other.GetComponent<TilemapCollider2D>().ClosestPoint(new Vector2(GetComponent<CapsuleCollider2D>().bounds.center.x + (0.8f * transform.parent.localScale.x),GetComponent<CapsuleCollider2D>().bounds.center.y)), Quaternion.Euler(0, 0, Random.Range(0, 360)));
So far 2 gives better results than 1. But with 2, the clash animation goes inside the wall instead of just outside at the edge of the wall.