Okay, this is a little tough to explain, but here goes:
I have a set of signal generators in an array. Depending on the effect I want, I assign a weight to each, then cycle through them to get a vector that represents the weighted sum of their input. (This lets me, for example, blend a square wave and a sine.) I then assign this value to an object’s transform.
First pass
Vector3 total = Vector3.zero;
foreach (SignalGen signal in signalGens) {
total += signal.Activate();
}
transform.position = total;
Trouble is, as you might already have noticed, that this operation will initially teleport the object to whatever total
might be.
Second pass
Adjust the blending code this way:
transform.Translate (total);
And adjust the signal function in this way:
Vector3 point = Generate (amplitude, velocity);
point -= oldPoint;
oldPoint = point;
return point;
This sort of works, but it spazzes out really quickly. At lower frequencies, for example, it increases the signal’s amplitude, which is just wrong.
Can some kind soul out there please put me out of my idiotic misery? I know I’m making an elementary mistake somewhere, but I just can’t figure it out.