Example #1
0
        public static ColliderPrefab CreateColliderPrefab(ColliderData data)
        {
            CBaseShape collider = null;

            if (LMath.Abs(data.deg - 45) < 1)
            {
            }

            //warning data.deg is unity deg
            //changed unity deg to ccw deg
            var collisionDeg = -data.deg + 90;

            if (data.radius > 0)
            {
                //circle
                collider = new CCircle(data.radius);
            }
            else
            {
                //obb
                collider = new COBB(data.size, collisionDeg);
            }

            collider.high = data.high;
            var colFab = new ColliderPrefab();

            colFab.parts.Add(new ColliderPart()
            {
                transform = new CTransform2D(data.pos, data.y, data.deg),
                collider  = collider
            });
            return(colFab);
        }
        public static ColliderPrefab CreateColliderPrefab(GameObject fab, ColliderData data)
        {
            Debug.Trace("CreateColliderPrefab " + fab.name);
            CBaseShape collider = null;

            if (data == null)
            {
                Debug.LogError(fab.name + " Miss ColliderDataMono ");
                return(null);
            }

            if (data.radius > 0)
            {
                //circle
                collider = new CCircle(data.radius);
            }
            else
            {
                //obb
                collider = new COBB(data.size, data.deg);
            }
            Debug.Trace($"{fab.name} !!!CreateCollider  deg: {data.deg} up:{data.size} radius:{data.radius}");
            var colFab = new ColliderPrefab();

            colFab.parts.Add(new ColliderPart()
            {
                transform = new CTransform2D(LVector2.zero),
                collider  = collider
            });
            return(colFab);
        }
Example #3
0
        public static ColliderPrefab CreateColliderPrefab(GameObject fab, ColliderData data)
        {
            Debug.Trace("CreateColliderPrefab " + fab.name);

            if (data == null)
            {
                Debug.LogError(fab.name + " Miss ColliderDataMono ");
                return(null);
            }

            Debug.Trace($"{fab.name} !!!CreateCollider  deg: {data.deg} up:{data.size} radius:{data.radius}");
            return(CreateColliderPrefab(data));
        }