// Update is called once per frame void Update() { // Decide on behavior ds_force = arrive.getSteering(); ds_torque = align.getSteering(); ds = new DynoSteering(ds_force.force, ds_torque.torque); // 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); transform.rotation = Quaternion.Euler(0f, kso.orientation * Mathf.Rad2Deg, 0f); }
// Update is called once per frame void Update() { ks = new KinematicSteering(); ds = new DynoSteering(); // Decide on behavior //seeking_output = seek.updateSteering(); //******seeking_output = arrive.getSteering(); seeking_output = arrive.getSteering(); ds_torque = align.getSteering(); //****** //seeking_output = seek.getSteering(); char_kinematic.setVelocity(seeking_output.velc); // Manually set orientation for now /*Replace these three lines with a dynamic rotation*/ //float new_orient = char_kinematic.getNewOrientation(seeking_output.velc); //char_kinematic.setOrientation(new_orient); //char_kinematic.setRotation(0f); ds.torque = ds_torque.torque; // Update Kinematic Steering kso = char_kinematic.updateSteering(ds, Time.deltaTime); transform.position = new Vector3(kso.position.x, transform.position.y, kso.position.z); transform.rotation = Quaternion.Euler(0f, kso.orientation * Mathf.Rad2Deg, 0f); /*record and write out speed on timer*/ string t = (Time.time - StartTime).ToString(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Grad School\AI\A1\" + FileName, true)) { file.WriteLine(t + " | " + char_kinematic.getVelocity().ToString()); } }
// Update is called once per frame void Update() { ds = new DynoSteering(); if (bHasGoal) { // Decide on behavior ds_force = arrive.getSteering(); ds_torque = align.getSteering(); } else { Vector3 tempGoal = ds_wander.getWanderGoal(char_RigidBody.getVelocity(), transform.position, toCenterWanderCircle, wanderCircleRad); //, UpperBoundX, LowerBoundX, UpperBoundZ, LowerBoundZ); ds_force = arrive.getSteering(tempGoal); ds_torque = align.getSteering(tempGoal); } ds.force = ds_force.force; ds.torque = ds_torque.torque; // 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); transform.rotation = Quaternion.Euler(0f, kso.orientation * Mathf.Rad2Deg, 0f); /*record and write out speed on timer*/ string t = (Time.time - StartTime).ToString(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Grad School\AI\A1\" + FileName, true)) { file.WriteLine(t + " | " + char_RigidBody.getVelocity().ToString()); } DropCrumb(char_RigidBody.getVelocity()); if (!(CheckInBounds(transform.position, UpperBoundX, LowerBoundX, UpperBoundZ, LowerBoundZ))) { char_RigidBody.setVelocity(char_RigidBody.getVelocity() * -1); //char_RigidBody.setRotation(char_RigidBody.getRotation () * -1); //char_RigidBody.setOrientation(char_RigidBody.getOrientation () - 180); //transform.Rotate (0, 180, 0); //float targetOrientation = char_RigidBody.getNewOrientation ((transform.position + char_RigidBody.getVelocity ())); //char_RigidBody.setRotation (targetOrientation - char_RigidBody.getOrientation ()); //char_RigidBody.setOrientation (targetOrientation); //char_RigidBody.setRotation (char_RigidBody.getRotation () - 180); //char_RigidBody.setOrientation /* * if (CheckInBounds (transform.position + (char_RigidBody.getVelocity () * -1), UpperBoundX, LowerBoundX, UpperBoundZ, LowerBoundZ)) * { * char_RigidBody.setVelocity (char_RigidBody.getVelocity () * -1); * } */ //transform.Rotate (0, 180, 0); //char_RigidBody.setOrientation( char_RigidBody() * (-1) );//char_RigidBody.getNewOrientation())// char_RigidBody.getOrientation() - 180 );//char_RigidBody.getNewOrientation (char_RigidBody.getVelocity ())); //transform.rotation = Quaternion.Euler (0, kso.orientation * Mathf.Rad2Deg * -1 ,0); //char_RigidBody.setRotation(char_RigidBody.getRotation () * -1); } }