private void OnCollisionEnter2D(Collision2D collision) { MovableObject movable = collision.collider.GetComponent <MovableObject>(); if (movable == null || collision.otherCollider.GetComponent <MovableObject>() == null) { return; } Vector2 pos = transform.position; Vector2 collidedPos = collision.transform.position; Vector2 baseCollision = -collision.GetContact(0).normal; float angle = Vector2.Angle(lastAggregate, baseCollision); float aggregateMultiplier = Mathf.Abs(90 - angle) / 90; if (angle < 0) { aggregateMultiplier *= -1; } //same thing for repulsive factor. Vector2 baseRepulsiveFactor = collision.otherCollider.GetComponent <MovableObject>().GetLastAggregateVelocityVector(); float repulsiveAngle = Vector2.Angle(baseRepulsiveFactor, baseCollision); float repulsiveMultiplier = Mathf.Abs(90 - repulsiveAngle) / 90; movable.AddForce(collision.otherCollider.gameObject, ((baseCollision) * repellantForceFactor * GameProperties.GetBaseCollisionForce()) + (lastAggregate * aggregateMultiplier) * GameProperties.GetCollisionVelocityTransferrance() * repellantForceFactor + baseRepulsiveFactor * repulsiveMultiplier * mirrorFactor); HandleCollidedMovableType(collision, movable); }