weird bug on updating transforms

in an iOS project, there is a 3D object which can be rotated and moved around on screen by the user. at the bottom of the screen is a drop shadow like this:

alt text

since i want the shadow to only move along the x axis, i’m using WorldToScreenPoint on the object and update the x value of the shadow’s localPosition accordingly.

Now the problem is when i’m moving the object around, the shadow will sort of jump around in a glitchy way, depending on the speed in which the object is moved… it’s further away from its intended position when i move the object faster, and is nice and steady and where it should be when the object isn’t moved. it is a bit hard to explain so here’s another pic:

alt text

Intuitively i would say that somehow the previous frame’s values are used for some of the transform calculations, or the order in which the scripts are executed is wrong? No idea how to fix this, since i’m quite unexperienced with U3D…

here’s the script which moves the shadow:

public class ShadowAligner : MonoBehaviour 
{
public Transform screenObject;
public Transform shadow;
public Camera cam;

float factor = 1;
public float y = 0;
public float z = 0;

void LateUpdate () 
{
	Vector3 screenPos = cam.WorldToScreenPoint(screenObject.position);
	float x = screenPos.x;
	Vector3 pos = shadow.localPosition;
	pos.x = map(x, 0, Screen.width, -factor, factor); 
	shadow.localPosition = new Vector3(pos.x, y, z);
}

float map(float value, float istart, float istop, float ostart, float ostop)
{
    return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}	
}

So, a couple of questions: Is the drop shadow a child of another object? When you use Transform.localPosition, you are moving the object relative to its parents, versus if you used Transform.position, which would be absolute. This could explain why it is moving faster than the cube, especially it’s already parented to the cube.

Secondly, why not skirt around this obstacle entirely by parenting the drop shadow to the cube, and simply explicitly set its Transform.position.y to a specific value, something like:

Transform.position = new Vector3(parent_Cube.transform.position.x,*constant y value*, 0f);

Thus only allow it to change the x based on the cube’s x movements.