public static SteeringOutput GetSteering(KinematicState ownKS, SAlign info) { SURROGATE_TARGET.rotation = Quaternion.Euler(SURROGATE_TARGET.eulerAngles.x, MathExtent.VectorToAngle(info.m_target.position - ownKS.m_position), SURROGATE_TARGET.eulerAngles.z); info.m_target = SURROGATE_TARGET; return(Align.GetSteering(ownKS, info)); }
public static SteeringOutput GetSteering(KinematicState ownKS, float wanderRate = 30f, float targetAngularRadius = 2f, float slowDownAngularRadius = 10f, float timeToDesiredAngularSpeed = 0.1f) { // align with a surrogate target that has your new orientation and go there // slightly change the orientation float desiredOrientation = ownKS.orientation + wanderRate * Utils.binomial(); // give that orientation to the surrogate target SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, desiredOrientation); // align with the surrogate target SteeringOutput al = Align.GetSteering(ownKS, SURROGATE_TARGET, targetAngularRadius, slowDownAngularRadius, timeToDesiredAngularSpeed); // go where you look (looked, actually) SteeringOutput gwyl = GoWhereYouLook.GetSteering(ownKS); // should never return null // combine, if possible if (al != null) { gwyl.angularActive = true; gwyl.angularAcceleration = al.angularAcceleration; } return(gwyl); }
public override SteeringOutput GetSteering() { // no KS? get it if (this.ownKS == null) { this.ownKS = GetComponent <KinematicState>(); } return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed)); }
public override SteeringOutput GetSteering() { // no KS? get it if (this.ownKS == null) { this.ownKS = GetComponent <KinematicState>(); } // being a rotational behaviour, align applies no rotational policy return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed)); }
public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float targetAngularRadius = 2f, float slowDownAngularRadius = 10f, float timeToDesiredAngularSpeed = 0.1f) { Vector3 directionToTarget = target.transform.position - ownKS.position; SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(directionToTarget)); // Align with surrogate target return(Align.GetSteering(ownKS, SURROGATE_TARGET, targetAngularRadius, slowDownAngularRadius, timeToDesiredAngularSpeed)); }
protected virtual void ApplyLWYG(SteeringOutput steering) { if (m_ownKS.m_linearVelocity.magnitude > 0.001f) { SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, MathExtent.VectorToAngle(m_ownKS.m_linearVelocity), 0); m_alignInfo.m_target = SURROGATE_TARGET; SteeringOutput st = Align.GetSteering(m_ownKS, m_alignInfo); steering.m_angularAcceleration = st.m_angularAcceleration; steering.m_angularActive = st.m_angularActive; } else { steering.m_angularActive = false; } }
public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float targetAngularRadius, float slowDownAngularRadius, float timeToDesiredAngularSpeed) { Vector3 directionToTarget = target.transform.position - ownKS.position; if (surrogateTarget == null) { surrogateTarget = new GameObject("Surrogate Target for Face"); } surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(directionToTarget)); // Align with surrogate target return(Align.GetSteering(ownKS, surrogateTarget, targetAngularRadius, slowDownAngularRadius, timeToDesiredAngularSpeed)); }
public virtual void applyLWYG(SteeringOutput steering) { if (ownKS.linearVelocity.magnitude > 0.001f) { // if linear velocity is very small, object is not moving (isn't going anywhere // hence it makes no sense to apply "look where you go" // Align with velocity. // create a surrogate target the orientation of which is that of my linear velocity SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, SURROGATE_TARGET); steering.angularAcceleration = st.angularAcceleration; steering.angularActive = st.angularActive; } else { steering.angularActive = false; } }
public override SteeringOutput GetSteering() { SteeringOutput result = WanderPlusAvoid.GetSteering(ownKS, wanderRate, wanderRate, wanderOffset, ref targetOrientation, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, ref avoidActive, avoidLayers, scanner); if (!surrogateTarget) { return(null); } if (ownKS.linearVelocity.magnitude > 0.001f) { surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget); result.angularAcceleration = st.angularAcceleration; result.angularActive = st.angularActive; } else { result.angularActive = false; } return(result); }
public override SteeringOutput GetSteering() { SteeringOutput result = LinearRepulsion.GetSteering(this.ownKS, this.idTag, this.repulsionThreshold); if (!surrogateTarget) { return(null); } if (ownKS.linearVelocity.magnitude > 0.001f) { surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget); result.angularAcceleration = st.angularAcceleration; result.angularActive = st.angularActive; } else { result.angularActive = false; } return(result); }
public override SteeringOutput GetSteering() { SteeringOutput result = Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset); if (!surrogateTarget) { return(null); } if (ownKS.linearVelocity.magnitude > 0.001f) { surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget); result.angularAcceleration = st.angularAcceleration; result.angularActive = st.angularActive; } else { result.angularActive = false; } return(result); }
public override SteeringOutput GetSteering() { SteeringOutput result = Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed); if (!surrogateTarget) { return(null); } if (ownKS.linearVelocity.magnitude > 0.001f) { surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget); result.angularAcceleration = st.angularAcceleration; result.angularActive = st.angularActive; } else { result.angularActive = false; } return(result); }
public override SteeringOutput GetSteering() { SteeringOutput result = ArrivePlusAvoid.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner, repulsionTag, repulsionThreshold, arriveWeight); if (!surrogateTarget) { return(null); } if (ownKS.linearVelocity.magnitude > 0.001f) { surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity)); SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget); result.angularAcceleration = st.angularAcceleration; result.angularActive = st.angularActive; } else { result.angularActive = false; } return(result); }
protected override SteeringOutput GetSteering() { return(Align.GetSteering(m_ownKS, m_info)); }
public override SteeringOutput GetSteering() { return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed)); }