Example #1
0
 void Start()
 {
     nav          = GetComponent <NavMeshAgent>();
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     enemy        = GetComponent <BlueEnemy>();
     bezierWalker = GetComponent <BezierWalkerWithSpeed>();
     destinationPoint.SetParent(null);
     startPoint = RandomPointOnSphere();
     nav.SetDestination(startPoint);
     destinationPoint.position = startPoint;
 }
Example #2
0
 void Awake()
 {
     defaultParent = transform.parent;
     if (bzWalker == null)
     {
         bzWalker = GetComponent <BezierSolution.BezierWalkerWithSpeed>();
     }
     foreach (GameObject g in legs)
     {
         Debug.Log("Found leg " + g.name + " in " + name);
     }
 }
Example #3
0
    private void CreateBeizer(GameObject startObj, GameObject targetObj)
    {
        GameObject   splineObj = new GameObject();
        BezierSpline spline    = splineObj.AddComponent <BezierSpline>();

        spline.Initialize(3);
        for (int i = 0; i < spline.Count; i++)
        {
            BezierPoint point = spline[i];
            if (i == 0)
            {
                point.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                point.followingControlPointLocalPosition = new Vector3(0.0f, 30.0f, 0.0f);
            }
            else if (i == 1)
            {
                point.localPosition = new Vector3(0.0f, -5f, 10.0f);
                point.followingControlPointLocalPosition = new Vector3(0.0f, -30.0f, 0.0f);
            }
            else if (i == 2)
            {
                point.localPosition = new Vector3(0.0f, 5f, 20.0f);
                point.followingControlPointLocalPosition = new Vector3(0.0f, -30.0f, 0.0f);
            }
        }

        if (mIsApply)
        {
            splineObj.transform.position = startObj.transform.position;
            Vector3 templateDir = spline[spline.Count - 1].position - spline[0].position;
            Vector3 actualDir   = targetObj.transform.position - startObj.transform.position;
            splineObj.transform.rotation = Quaternion.FromToRotation(templateDir, actualDir);
            templateDir = spline[spline.Count - 1].position - spline[0].position;
            float scale = actualDir.magnitude / templateDir.magnitude;
            splineObj.transform.localScale = new Vector3(scale, scale, scale);

            mBezierWalker        = startObj.AddComponent <BezierWalkerWithSpeed>();
            mBezierWalker.Spline = spline;
        }
    }
Example #4
0
    // Use this for initialization
    void Awake()
    {
        GM = Object.FindObjectOfType <GameManager>();
        if (GM == null)
        {
            Debug.Log("No GameManager found.");
        }
        bzWalker = GetComponent <BezierWalkerWithSpeed>();
        //Get nearest

        /*float dist = Vector3.Distance(transform.position, speedTargets[currentSpeedIndex].GetComponent<Transform>().position);
         * foreach(SpeedTarget st in speedTargets){
         *      if(currentSpeedIndex + 1 < speedTargets.Count){
         *              float d2 = Vector3.Distance(transform.position, speedTargets[currentSpeedIndex+1].GetComponent<Transform>().position);
         *              if(d2 < dist){
         *                      currentSpeedIndex++;
         *              }
         *      }
         * }*/
        bzWalker.speed = speeds[0];
        speedToAttain  = speeds[currentSpeedIndex];
    }
 private void Awake()
 {
     walker       = GetComponent <BezierWalkerWithSpeed>();
     walker.speed = 0;
 }