Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (dynoArrive)
     {
         if (dynoArrive.HasArrived())
         {
             goal_index++;
             goal_index %= ordered_goals.Count;
             goal_script.setGoal(ordered_goals[goal_index]);
         }
     }
     else
     {
         if (kinematicArrive.HasArrived())
         {
             goal_index++;
             goal_index %= ordered_goals.Count;
             goal_script.setGoal(ordered_goals[goal_index]);
         }
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (isWandering)
        {
            //CheckForWallAndTakeDecision();
        }

        if (isWandering)
        {
            GetWanderGoal();
            ds_force = arrive.getSteering();
            ds       = align.getSteering();
            ds.force = ds_force.force;
        }
        else
        {
            KinematicSteering ks = kinematicArrive.getSteering();

            char_RigidBody.setVelocity(ks.velc);

            //instantly set rotation
            float new_orient = char_RigidBody.getNewOrientation(ds_force.force);
            char_RigidBody.setOrientation(new_orient);
            char_RigidBody.setRotation(0f);
        }

        // Update Kinematic Steering
        kso = char_RigidBody.updateSteering(ds, Time.deltaTime);
        //Debug.Log(kso.position);
        transform.position = new Vector3(kso.position.x, transform.position.y, kso.position.z);
        float rotation = kso.orientation * Mathf.Rad2Deg;

        transform.rotation = Quaternion.Euler(0f, rotation, 0f);

        if (!isWandering && (arrive.HasArrived() || kinematicArrive.HasArrived()))
        {
            isWandering = true;
        }
    }