Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (t1.targetPoints.Count >= 1)
        {
            if (g1.obj[0] != null)
            {
                LineRenderObject t2 = g1.obj[0].GetComponent <LineRenderObject>();

                if (t2.targetPoints.Count >= 1)
                {
                    targetPath = new NavMeshPath();
                    agent.SetDestination(t2.targetPoints[0]);
                    agent.CalculatePath(t2.targetPoints[0], targetPath);
                    //Debug.Log("残り距離をみています");
                    //Debug.Log(agent.remainingDistance);

                    var destinationVec = t2.targetPoints[0] - transform.position;
                    destinationVec = destinationVec.normalized;
                    if (t2.targetPoints.Count > 1)
                    {
                        //rigidbodyCylinder.AddForce(destinationVec*10);
                        if (agent.remainingDistance < 0.5)
                        {
                            //if(targetLinePointCount<t2.targetPoints.Count-1)
                            //targetLinePointCount++;
                        }
                    }
                }
            }
        }
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     refObj                = GameObject.Find("LineRenderObjectPrefab");
     refLineObj            = GameObject.Find("InstanceManager");
     agent                 = GetComponent <NavMeshAgent>();
     playerToPointDistance = 10;
     targetLinePointCount  = 0;
     t1 = refObj.GetComponent <LineRenderObject>();
     g1 = refLineObj.GetComponent <InstanceManager>();
     rigidbodyCylinder = GetComponent <Rigidbody>();
 }