Moving an object's shadow in a straight line below a parabola


I have a 2D character that jumps across the screen in a parabola. I know the starting position and the target position of the jump.

I want to have a shadow object that tracks the character directly below him. So, the shadow would just move on a straight line between the starting and target positions.

I have the vector necessary by subtracting the starting position from the ending position. What I need is some way to get the position along that vector given the character’s position along the parabola. So basically, plug in the character’s X position, and get back the shadow’s Y position below the character.

Anyone understand the math here well enough to help out? Thank you for any help.

robertbu - Yes I think you’re right and I think that is how I solved it last night. I already had the travel vector so I just put down the shadow transform on that line before I did the calculation to turn it into a parabola. Here is the code from the coroutine. This is on the character who I’m moving in a parabola.

If anyone has a recommendation for doing this via Transform.translate instead of using a “new Vector3” every frame, I would appreciate it.

            while (curTime < jumpTime)
                float parabolicT = curTime * 2 - 1;

                GetComponent<CircleCollider2D>().enabled = false;

                Vector3 travelDirection = end - start;
                Vector3 levelDirecteion = end - new Vector3(start.x, end.y, start.z);
                Vector3 right = Vector3.Cross(travelDirection, levelDirecteion);
                Vector3 up = Vector3.Cross(right, travelDirection);
                if (end.y > start.y) up = -up;
                Vector3 result = start + curTime * travelDirection;
                shadow.transform.position = new Vector3(transform.position.x, result.y, -1);
                result += ((-parabolicT * parabolicT + 1) * height) * up.normalized;
                this.transform.position = result;

                curTime += Time.deltaTime + jumpSpeedMult;

                yield return null;