private static PanelColliderSerializer PanelColliderToSerializer(SpringPanelCollider sourceCollider)
 {
     return(new PanelColliderSerializer
     {
         baseInfo = TransformToColliderSerializerBaseInfo(sourceCollider.transform, PanelColliderToken),
         width = sourceCollider.width,
         height = sourceCollider.height,
         linkedRenderer = GetComponentName(sourceCollider.linkedRenderer)
     });
 }
Exemplo n.º 2
0
        private bool CheckForGroundCollision()
        {
            // Todo: this assumes a flat ground parallel to the xz plane
            var worldHeadPosition = transform.position;
            var worldTailPosition = currTipPos;
            var worldRadius       = transform.TransformDirection(radius, 0f, 0f).magnitude;
            var worldLength       = (currTipPos - worldHeadPosition).magnitude;
            var groundHeight      = manager.groundHeight;

            worldHeadPosition.y -= groundHeight;
            worldTailPosition.y -= groundHeight;
            var collidingWithGround = SpringPanelCollider.CheckForCollisionWithAlignedPlaneAndReact(
                worldHeadPosition, worldLength, ref worldTailPosition, worldRadius, SpringPanelCollider.Axis.Y);

            if (collidingWithGround != CollisionStatus.NoCollision)
            {
                worldTailPosition.y += groundHeight;
                currTipPos           = FixBoneLength(transform.position, worldTailPosition, 0.5f * springLength, springLength);
                // Todo: bounce, friction
                prevTipPos = currTipPos;
            }

            return(collidingWithGround != CollisionStatus.NoCollision);
        }