Hey, hopefully an easy question to answer.
I have an object (textItem) that needs to follow another object (planeItem). I can achieve this no problem using the following code in Update():
public static void AlignWithPlane(GameObject textItem, GameObject planeItem, float yOffset = 0.0f, float xOffset = -0.9f, float zOffset = -0.05f)
{
var v3Offset = new Vector3(xOffset, yOffset, zOffset);
textItem.transform.position = planeItem.transform.TransformPoint(v3Offset);
textItem.transform.rotation = planeItem.transform.rotation;
}
However OnMouse* events are not triggered for the textItem when the planeItem is travelling at a high velocity. At slower speeds it is the same but intermittent.
If I understand correctly, the update code is slowly behind the planeItem so while the visual representation is fine (it’s drawn right), the actual collider hasn’t caught up yet?
Is there a way to translate the position of the textItem to the position of the planeItem both with movement and zero movement?
NOTE: I am bound by the rule of not being able to parent the textItem to the planeItem. This is unconditional for the scenario.
I would really appreciate any help. 
Here’s a script that should help you. You’ll need to adjust it for all three axis however.
`using UnityEngine;
using System.Collections;
public class FollowObject : MonoBehaviour {
//Holds the vectors for the objects translation.
Vector3 ObjTrans; //Vector3 holding new translation coords.
public float ObjSpeed; //The speed at which the object moves.
public Transform Object; //The target object for the camera.
public Vector3 Offset; //An offset for the Object from the target object.
public Vector2 NegBounds; //Bounding volumes to signal when the Object should be updated.
public Vector2 PosBounds; //Bounding volumes to signal when the Object should be updated.
bool update_x=false; //Signals when the Object should be updated.
bool update_y=false;
// Use this for initialization
void Start ()
{
ObjTrans.x = this.transform.position.x;
ObjTrans.y = this.transform.position.y;
ObjTrans.z = this.transform.position.z;
}
void Update()
{
UpdateBoundingVolumes();
//Check to see if our object is outside of the follow bounding volume.
if(Object.position.x<NegBounds.x||Object.position.x>PosBounds.x)
{
update_x=true;
}
else
{
update_x=false;
}
if(Object.position.y<NegBounds.y||Object.position.y>PosBounds.y)
{
update_y=true;
}
else
{
update_y=false;
}
Follow();
}
public void Follow() //!< Sets the transform for the Object to follow another specified object on the y axis. Takes a reference to said object. Must be updated in a scene loop.
{
if(update_x && update_y)
{
ObjTrans = new Vector3(Object.position.x,Object.position.y,Offset.z);
}
else if(update_x && !update_y)
{
ObjTrans = new Vector3(Object.position.x,this.transform.position.y,Offset.z);
}
else if(!update_x && update_y)
{
ObjTrans = new Vector3(this.transform.position.x,Object.position.y,Offset.z);
}
transform.position= Vector3.Lerp(transform.position,ObjTrans,Time.deltaTime*ObjSpeed);
}
void UpdateBoundingVolumes()
{
NegBounds.x = transform.position.x - Offset.x;
NegBounds.y = transform.position.y - Offset.y;
PosBounds.x = transform.position.x + Offset.x;
PosBounds.y = transform.position.y + Offset.y;
}
`
Hope it helps. Copy this, save it, put it in your project. Add it as a component to the object you want to be following. Assign the other object follow in the editor.