示例#1
0
        private static void ResolveCollision(CircleCollider c1, BoxCollider c2)
        {
            float pointX = MathHelper.Clamp(
                c1.GetPosition().X,
                c2.GetPosition().X - c2.width / 2,
                c2.GetPosition().X + c2.width / 2);

            float pointY = MathHelper.Clamp(
                c1.GetPosition().Y,
                c2.GetPosition().Y - c2.height / 2,
                c2.GetPosition().Y + c2.height / 2);

            Vector2 point = new Vector2(pointX, pointY);

            // hacki soł macz
            tempGO.transform.position = point;
            tempCC.SetReaction(c2.GetReaction());
            ResolveCollision(c1, tempCC);
        }