Пример #1
0
        void Move()
        {
            if (player1 && player2 && gameManager.gameState == MightyGamePack.GameState.Playing)
            {
                middleLinePoint = player1.transform.position - (player1.transform.position - player2.transform.position) * 0.5f;
                targetPoint     = middleLinePoint + MightyUtilites.PerpendicularToLine(player1.transform.position, player2.transform.position) * length + new Vector3(0, height, 0);

                if (moveToAction)
                {
                    transform.position = Vector3.Lerp(transform.position, targetPoint, movementSmoothness * Time.deltaTime);
                }

                if (lookAtAction)
                {
                    Quaternion targetRotation = Quaternion.LookRotation(middleLinePoint + lookAtTargetOffset - transform.position, Vector3.up);
                    transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, lookAtSmoothness * Time.deltaTime);
                }
            }
        }
Пример #2
0
        private void OnDrawGizmos()
        {
            if (drawGizmos && player1 && player2)
            {
                Vector3 middleLinePointGizmo = player1.transform.position - (player1.transform.position - player2.transform.position) * 0.5f;
                Vector3 lengthPoint          = middleLinePointGizmo + MightyUtilites.PerpendicularToLine(player1.transform.position, player2.transform.position) * length;

                if (moveToAction)
                {
                    Gizmos.DrawLine(player1.transform.position, player2.transform.position);
                    Gizmos.DrawLine(middleLinePointGizmo, lengthPoint);
                    Gizmos.DrawLine(lengthPoint, lengthPoint + new Vector3(0, height, 0));
                    Gizmos.DrawSphere(lengthPoint + new Vector3(0, height, 0), 0.5f);
                }

                if (lookAtAction)
                {
                    Gizmos.DrawSphere(middleLinePointGizmo + lookAtTargetOffset, 0.5f);
                    Gizmos.DrawLine(transform.position, middleLinePointGizmo + lookAtTargetOffset);
                }
            }
        }