Пример #1
0
        private void Init()
        {
            Mecha mecha = GetComponentInParent <Mecha>();

            if (mecha == null)
            {
                Debug.LogError("Mecha script was not found in chain. Please add!");
                return;
            }
            mecha.ikSolver.Init(this);
            mecha.ik_Legs.Add(this);
            switch (type)
            {
            case LimbType.None:
                break;

            case LimbType.Leg:
                var legData = new LegData(endEffector, root, target);
                legData.bezierStartPosition = endEffector.position;
                legData.bezierHandle1       = endEffector.position + mecha.legRaiseFromGround * mecha.scaleFactor;
                legData.bezierEndPosition   = endEffector.position;
                legData.bezierHandle2       = endEffector.position + mecha.legRaiseFromGround * mecha.scaleFactor;
                mecha.legsData.Add(legData);
                break;
            }
        }
Пример #2
0
        void OnSceneGUI()
        {
            Mecha m = (Mecha)target;

            //Handles.color = Handles.zAxisColor;
            //Handles.ArrowHandleCap(0, m.transform.position, Quaternion.LookRotation(m.transform.forward, m.arrowAngle), arrowSize, EventType.Repaint);
            WhileRunning(m);
        }
Пример #3
0
 private void WhileRunning(Mecha m)
 {
     if (Application.isPlaying)
     {
         for (int i = 0; i < m.legsData.Count; i++)
         {
             var leg = m.legsData[i];
             DrawCurve(leg.bezierStartPosition,
                       leg.bezierEndPosition,
                       leg.bezierHandle1,
                       leg.bezierHandle2);
         }
     }
 }
Пример #4
0
        static void DrawForces(Mecha mecha, GizmoType gizmoType)
        {
            Debug.DrawRay(mecha.transform.position, mecha.velocity);
            Debug.DrawRay(mecha.transform.position, mecha.legForce, Color.magenta);
            Debug.DrawRay(mecha.transform.position, mecha.gravityForce, Color.yellow);
            if (Application.isPlaying)
            {
                var p0 = mecha.legsData[0].bezierStartPosition;
                var p1 = mecha.legsData[0].bezierHandle1;
                var p2 = mecha.legsData[0].bezierHandle2;
                var p3 = mecha.legsData[0].bezierEndPosition;

                Gizmos.color = Color.red;
                Gizmos.DrawWireSphere(p1, 0.1f);
                Gizmos.color = Color.yellow;
                Gizmos.DrawWireSphere(p2, 0.1f);
                Gizmos.color = Color.blue;
                Gizmos.DrawWireSphere(mecha.legsData[0].target.position, 0.1f);
            }
        }
Пример #5
0
 public IMechLegs(Mecha parent)
 {
     this.mech = parent;
 }
Пример #6
0
 void Start()
 {
     mecha = GetComponentInParent <Mecha>();
 }
Пример #7
0
 void Start()
 {
     hips = GetComponentInChildren <Hips>();
     mech = GetComponent <Mecha>();
 }