//Debug print for GetData private void PrintData(float dist, float mu, FFVector3 n1, FFVector3 p1) { Debug.Log("Dist: " + dist); Debug.Log("mu: " + mu); Debug.Log("n1: " + "(" + n1.x + "," + n1.y + "," + n1.z + ")"); Debug.Log("p1: " + "(" + p1.x + "," + p1.y + "," + p1.z + ")"); }
public void FireBullet(double time, FFVector3 position) { // Fire transform.position = position; moveSequence = action.Sequence(); moveSequence.TimeWarpFrom(time); FireSequenceCall(); // Death deathSequence = action.Sequence(); deathSequence.Delay(TimeToLive); deathSequence.Sync(); deathSequence.Call(DestroyBullet); }
private void GetData(float dist, out float mu, out FFVector3 n1, out FFVector3 n2, out FFVector3 p1, out FFVector3 p2) { dist = Mathf.Abs(dist); if (points.Length > 1) { int i = 0; int first = 1; int middle = PointCount / 2; int last = PointCount - 1; // do not mod unless >, so that we can move to the end of the path if (dist > PathLength) { dist = dist % PathLength; } while (first <= last) { if (dist > (linearDistanceAlongPath[middle])) // greater than { first = middle + 1; } else if (dist >= (linearDistanceAlongPath[middle - 1]) && // equal to dist <= (linearDistanceAlongPath[middle])) { i = middle; break; } else // less than (dist < linearDistanceAlongPath[middle - 1]) { last = middle - 1; } middle = (first + last) / 2; } if (Circuit) // line loops back to first point from the last point { int n2Index = i - 2 < 0 ? points.Length - 1 : i - 2; int n1Index = (i - 1) % points.Length; int p1Index = i % points.Length; int p2Index = (i + 1) % points.Length; n2.x = points[n2Index].x; n2.y = points[n2Index].y; n2.z = points[n2Index].z; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; p2.x = points[p2Index].x; p2.y = points[p2Index].y; p2.z = points[p2Index].z; mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]); // length of interval between points return; } else // Line ends and then begins again... { int n2Index = i - 2 < 0 ? points.Length - 1 : i - 2; int n1Index = (i - 1); int p1Index = i; int p2Index = (i + 1) % points.Length; n2.x = points[n2Index].x; n2.y = points[n2Index].y; n2.z = points[n2Index].z; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; p2.x = points[p2Index].x; p2.y = points[p2Index].y; p2.z = points[p2Index].z; float lengthBetweenPoints = linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]; if (lengthBetweenPoints > 0.0f) { mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (lengthBetweenPoints); // length of interval between points } else // zero distance between points { mu = 0.0f; } return; } } p1.x = -0.1f; p1.y = -0.1f; p1.z = -0.1f; n1 = n2 = p2 = p1; mu = 0; }
private void GetData(float dist, out float mu, out FFVector3 n1, out FFVector3 p1) { dist = Mathf.Abs(dist); if (points.Length > 1) { int i = 0; int first = 1; int middle = PointCount / 2; int last = PointCount - 1; // do not mod unless >, so that we can move to the end of the path if (dist > PathLength) { dist = dist % PathLength; } while (first <= last) { if (dist > (linearDistanceAlongPath[middle])) // greater than { first = middle + 1; } else if (dist >= (linearDistanceAlongPath[middle - 1]) && // equal to dist <= (linearDistanceAlongPath[middle])) { i = middle; break; } else // less than (dist < linearDistanceAlongPath[middle - 1]) { last = middle - 1; } middle = (first + last) / 2; } int n1Index = i - 1; // TODO remove? int p1Index = i % points.Length; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; float lengthBetweenPoints = linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]; if (lengthBetweenPoints > 0.0f) { mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (lengthBetweenPoints); // length of interval between points } else // zero distance between points { mu = 0.0f; } return; } p1.x = -0; p1.y = -0; p1.z = -0; n1 = p1; mu = 0; }
//Debug print for GetData private void PrintData(float dist, float mu, FFVector3 n1, FFVector3 n2, FFVector3 p1, FFVector3 p2) { Debug.Log("Dist: " + dist); Debug.Log("mu: " + mu); Debug.Log("n2: " + "(" + n2.x + "," + n2.y + "," + n2.z + ")"); Debug.Log("n1: " + "(" + n1.x + "," + n1.y + "," + n1.z + ")"); Debug.Log("p1: " + "(" + p1.x + "," + p1.y + "," + p1.z + ")"); Debug.Log("p2: " + "(" + p2.x + "," + p2.y + "," + p2.z + ")"); }
private void GetData(float dist, out float mu, out FFVector3 n1, out FFVector3 n2, out FFVector3 p1, out FFVector3 p2) { dist = Mathf.Abs(dist); if (points.Length > 1) { int i = 0; int first = 1; int middle = PointCount / 2; int last = PointCount - 1; // do not mod unless >, so that we can move to the end of the path if (dist > PathLength) dist = dist % PathLength; while (first <= last) { if (dist > (linearDistanceAlongPath[middle])) // greater than { first = middle + 1; } else if (dist >= (linearDistanceAlongPath[middle - 1]) // equal to && dist <= (linearDistanceAlongPath[middle])) { i = middle; break; } else // less than (dist < linearDistanceAlongPath[middle - 1]) { last = middle - 1; } middle = (first + last) / 2; } if (Circuit) // line loops back to first point from the last point { int n2Index = i - 2 < 0 ? points.Length - 1 : i - 2; int n1Index = (i - 1) % points.Length; int p1Index = i % points.Length; int p2Index = (i + 1) % points.Length; n2.x = points[n2Index].x; n2.y = points[n2Index].y; n2.z = points[n2Index].z; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; p2.x = points[p2Index].x; p2.y = points[p2Index].y; p2.z = points[p2Index].z; mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]); // length of interval between points return; } else // Line ends and then begins again... { int n2Index = i - 2 < 0 ? points.Length - 1 : i - 2; int n1Index = (i - 1); int p1Index = i; int p2Index = (i + 1) % points.Length; n2.x = points[n2Index].x; n2.y = points[n2Index].y; n2.z = points[n2Index].z; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; p2.x = points[p2Index].x; p2.y = points[p2Index].y; p2.z = points[p2Index].z; float lengthBetweenPoints = linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]; if (lengthBetweenPoints > 0.0f) { mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (lengthBetweenPoints); // length of interval between points } else // zero distance between points { mu = 0.0f; } return; } } p1.x = -0.1f; p1.y = -0.1f; p1.z = -0.1f; n1 = n2 = p2 = p1; mu = 0; }
private void GetData(float dist, out float mu, out FFVector3 n1, out FFVector3 p1) { dist = Mathf.Abs(dist); if (points.Length > 1) { int i = 0; int first = 1; int middle = PointCount / 2; int last = PointCount - 1; // do not mod unless >, so that we can move to the end of the path if (dist > PathLength) dist = dist % PathLength; while (first <= last) { if (dist > (linearDistanceAlongPath[middle])) // greater than { first = middle + 1; } else if (dist >= (linearDistanceAlongPath[middle - 1]) // equal to && dist <= (linearDistanceAlongPath[middle])) { i = middle; break; } else // less than (dist < linearDistanceAlongPath[middle - 1]) { last = middle - 1; } middle = (first + last) / 2; } int n1Index = i - 1; // TODO remove? int p1Index = i % points.Length; n1.x = points[n1Index].x; n1.y = points[n1Index].y; n1.z = points[n1Index].z; p1.x = points[p1Index].x; p1.y = points[p1Index].y; p1.z = points[p1Index].z; float lengthBetweenPoints = linearDistanceAlongPath[i] - linearDistanceAlongPath[i - 1]; if(lengthBetweenPoints > 0.0f) { mu = (dist - linearDistanceAlongPath[i - 1]) // dist's length into Interval of points / (lengthBetweenPoints); // length of interval between points } else // zero distance between points { mu = 0.0f; } return; } p1.x = -0; p1.y = -0; p1.z = -0; n1 = p1; mu = 0; }