public override Goal Suggest(LineSegmentPath path, KinematicData character, Goal goal) { // procurar ponto do segmento mais próximo ao centro da esfera Vector3 closest = path.GetPosition(MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, Troll.KinematicData.position)); // Check if we pass through the center point Vector3 newPt; if (closest.sqrMagnitude == 0) { // Get any vector at right angles to the segment Vector3 dirn = path.EndPosition - path.StartPosition; //pode nao ser esta func TO DO Vector3 newdirn = Vector3.Cross(dirn, Vector3.Cross(dirn, Vector3.forward)); newPt = Troll.KinematicData.position + newdirn * TrollRadius * margin; } else { // Otherwise project the point out beyond the radius newPt = (Troll.KinematicData.position + (closest - Troll.KinematicData.position) * TrollRadius * margin) / closest.sqrMagnitude; } // Set up the goal and return goal.position = newPt; return goal; }
public override Vector3 GetPosition(float param) { int i = (int)Math.Floor(param); //HERE LineSegmentPath path = LocalPaths[i] as LineSegmentPath; return path.GetPosition(param - i); }
public override Boolean WillViolate(LineSegmentPath path) { Vector3 impactPoint = path.GetPosition(MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, Troll.KinematicData.position)); Vector3 direction = Troll.KinematicData.position - impactPoint; float distance = Vector3.Magnitude(direction); if(distance < TrollRadius) { // Debug.Log("VIOLATE!"); return true; } // Debug.Log("NO VIOLATE!"); return false; }
public override Vector3 GetPosition(float param) { //TODO: implement latter int localPathIndex = (int)Math.Truncate(param); if (localPathIndex + 1 < this.PathPositions.Count) { LineSegmentPath segment = new LineSegmentPath(PathPositions[localPathIndex], PathPositions[localPathIndex + 1]); return(segment.GetPosition(param)); } else { return(this.PathPositions[this.PathPositions.Count - 1]); } }