// Update is called once per frame protected override void Update() { steeringUpdate = new SteeringOutput(); steeringUpdate.linear = myRotateType.getSteering().linear; steeringUpdate.angular = myRotateType.getSteering().angular; base.Update(); }
// Update is called once per frame void Update() { Vector3 target = wander.getTarget(); Vector3 accel = wander.getSteering(target); steeringBasics.steer(accel); steeringBasics.lookWhereYoureGoing(target); }
// Update is called once per frame void Update() { ks = new KinematicSteering(); ds = new DynoSteering(); // Decide on behavior //seeking_output = seek.updateSteering(); //seeking_output = seek.getSteering(); //seeking_output = arrive.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); Vector3 acceleration = wander.getSteering(); ds.force = acceleration; // Update Kinematic Steering kso = char_kinematic.updateSteering(ds, Time.deltaTime); transform.position = new Vector3(kso.position.x, transform.position.y, kso.position.z); Vector2 direction = new Vector2(char_kinematic.getVelocity().x, char_kinematic.getVelocity().z); float turnSpeed = 20.0f; direction.Normalize(); // If we have a non-zero direction then look towards that direciton otherwise do nothing if (direction.sqrMagnitude > 0.001f) { float toRotation = (Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg); float rotation = Mathf.LerpAngle(transform.rotation.eulerAngles.y, toRotation, Time.deltaTime * turnSpeed); transform.rotation = Quaternion.Euler(0, rotation, 0); } // transform.rotation = Quaternion.Euler(0f, kso.orientation * Mathf.Rad2Deg, 0f); }
// Update is called once per frame void Update() { Debug.Log(behaviour); Vector3 forward = transform.TransformDirection(Vector3.forward); Debug.DrawRay(transform.position, forward, Color.green); RaycastHit hit; if (behaviour == Behaviour.LookingFor) { if (Physics.Raycast(transform.position, forward, out hit)) { Vector3 HitForward = hit.transform.TransformDirection(Vector3.forward); RB.velocity = Vector3.zero; if (Vector3.Dot(forward, HitForward) > 0) { transform.Rotate(Vector3.up, -5 * turnSpeed * Time.deltaTime); } else { transform.Rotate(Vector3.up, 5 * turnSpeed * Time.deltaTime); } if (hit.distance > 5.0f) { behaviour = Behaviour.MoveTo; target = transform.position + forward * 5.0f; MT.SetTarget(target); } lookWhereYoureGoing(); return; } } if (behaviour == Behaviour.MoveTo) { Vector3 acceleration = MT.getSteering(); Debug.Log("MoveTo: " + acceleration); RB.velocity += acceleration * Time.deltaTime; if (MT.GetTarget()) { behaviour = Behaviour.Wander; } if (RB.velocity.magnitude > maxVelocity) { RB.velocity = RB.velocity.normalized * maxVelocity; } lookWhereYoureGoing(); return; } else { Vector3 acceleration = WD.getSteering(); RB.velocity += acceleration * Time.deltaTime; if (Physics.Raycast(transform.position, forward, out hit)) { if (hit.distance <= 2.0f) { RB.velocity = Vector3.zero; behaviour = Behaviour.LookingFor; return; } } if (RB.velocity.magnitude > maxVelocity) { RB.velocity = RB.velocity.normalized * maxVelocity; } lookWhereYoureGoing(); } }
// Update is called once per frame void Update() { steeringAgent.UpdateSteering(wander.getSteering()); }