Example #1
0
        public static GameObject GenerateGoal(Vector3 center, float radius, int numCirclePoints)
        {
            GameObject goalGO = new GameObject();

            goalGO.SetActive(false);
            goalGO.name = "Goal";
            goalGO.transform.position = center;

            // Add a LineRenderer to display the goal
            LineRenderer lr = goalGO.AddComponent <LineRenderer>();

            SetLineRendererSettings(lr);
            // Add a debugScript that lets you see into the goal's settings
            // and that also managers setting the LineRenderer
            GoalDebug debugScript = goalGO.AddComponent <GoalDebug>();

            debugScript.radius = radius;
            // Add points for the circle
            List <Vector3> lrPositions = CalculateCirclePoints(center, radius, numCirclePoints);

            debugScript.SetPositions(lrPositions);
            lr.material = GenerateGoalMaterial();

            goalGO.SetActive(true);

            return(goalGO);
        }
        public bool GoalMet(GameObject goalGO, GameObject jointObj)
        {
            bool goalMet = false;

            if (goalGO != null)
            {
                GoalDebug goal = goalGO.GetComponent <GoalDebug>();
                if (goal != null)
                {
                    //goalMet = goal.GoalMet(joint.Position);
                    goalMet = goal.GoalMet(jointObj.transform.position);
                }
            }

            return(goalMet);
        }