Hello!
I am unable to bind AnimationCurve to a local object transform.
If you do something like that
public AnimationCurve animCurve;
public GameObject target;
float curveTimer = 0f;
// (1, 0, 0) – x
// (0, 1, 0) – y
// (0, 0, 1) – z
public Vector3 vector = new Vector3(0, 1, 0);
void Update()
{
curveTimer += Time.deltaTime;
if (curveTimer > 2)
curveTimer = 0;
float curveAmount = animCurve.Evaluate(curveTimer);
target.transform.localPosition = vector * curveAmount;
}
Everything moves as it should
gif1
BUT if the object is locally rotated, then it does not move quite as it should.
gif2
As I understand it, need to use Vector3.up (forward or right depending on which axis).
But it works the same way and nothing changes. Ithink need to somehow use the direction
How do I snap an AnimationCurve so that the curve controls the position of the object, like this:
gif3