// Update is called once per frame void Update() { ks = new KinematicSteering(); ds = new DynoSteering(); ds.torque = align.getSteering().torque; // Decide on behavior //seeking_output = seek.updateSteering(); seeking_output = arrive.getSteering(); //seeking_output = seek.getSteering(); char_kinematic.setVelocity(seeking_output.velc); // Manually set orientation for now //float new_orient = char_kinematic.getNewOrientation(seeking_output.velc); //char_kinematic.setOrientation(new_orient); //char_kinematic.setRotation(0f); // 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); //Logger.instance.WriteToFileKinematic("speed: " + char_kinematic.getVelocity().magnitude + " time: " + Time.time); }
// Update is called once per frame void Update() { ds = new DynoSteering(); // Decide on behavior //seeking_output = seek.updateSteering(); seeking_output = arrive.getSteering(); //seeking_output = seek.getSteering(); char_kinematic.setVelocity(seeking_output.velc); // Manually set orientation for now if (dynoAlign && dynoAlign.enabled) { ds = dynoAlign.getSteering(); } else { float new_orient = char_kinematic.getNewOrientation(seeking_output.velc); char_kinematic.setOrientation(new_orient); char_kinematic.setRotation(0f); } // 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); if (recordLogs && logWriter && logWriter.enabled) { logWriter.Write(char_kinematic.getVelocity().magnitude.ToString()); } }
public DynoSteering getSteering() { Vector3 direction = goal.position - transform.position; if (direction.magnitude != 0.0f) { align.goal = goal; align.targetOrientation = Mathf.Atan2(-direction.x, direction.z); } return(align.getSteering()); }
// Update is called once per frame void Update() { // Decide on behavior ds_force = arrive.getSteering(); ds_torque = align.getSteering(); ds = new DynoSteering(); 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); }
// Update is called once per frame void Update() { // Decide on behavior ds_force = arrive.getSteering(); //ds_force = wander.getSteering(); ds_torque = align.getSteering(); //ds_torque = wander.getSteering(); ds = new DynoSteering(); 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); //Logger.instance.WriteToFileDynamic("speed: " + char_RigidBody.getVelocity().magnitude + " time: " + Time.time); }
// Update is called once per frame void Update() { // Decide on behavior ds_force = arrive.getSteering(); ds_torque = align.getSteering(); ds = new DynoSteering(); 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); if (recordLogs && logWriter && logWriter.enabled) { logWriter.Write(char_RigidBody.getVelocity().magnitude.ToString()); } }
// 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; } }
// Update is called once per frame void Update() { //Check for click if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.GetMask("Floor"))) { //Get Path Vector3 destination = hit.collider.transform.position; Vector3 start = transform.position; path = levelManager.GetShortestPath(start, destination); currentGoal = 0; isLastGoal = false; if (finalGoal) { finalGoal.GetComponent <Renderer>().material = defaultMaterial; } finalGoal = hit.collider.gameObject; finalGoal.GetComponent <Renderer>().material = selected; } } //Update goal positions if (currentGoal < path.Count) { if (seek.HasArrived()) { goalObject.transform.position = path[currentGoal]; goal.setGoal(goalObject); currentGoal++; if (currentGoal == path.Count) { isLastGoal = true; } } } // Decide on behavior if (isLastGoal) { ds_force = arrive.getSteering(); } else { ds_force = seek.getSteering(); } ds_torque = align.getSteering(); ds = new DynoSteering(); ds.force = ds_force.force; ds.torque = ds_torque.torque; // Update Kinematic Steering kso = char_RigidBody.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); if (recordLogs && logWriter && logWriter.enabled) { logWriter.Write(char_RigidBody.getVelocity().magnitude.ToString()); } }