When I am dragging one object, I want another object in the scene to move as well. At the moment I have pretty simple scripts attached. Here is the one on the object that drags:
function Update(){
StaticVarDisc.PosX = transform.position.x; //this is defining posx etc
StaticVarDisc.PosY = transform.position.y;
StaticVarDisc.PosZ = transform.position.z;
if (drag){
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var distance: float;
if (plane.Raycast(ray, distance)){
transform.position = ray.GetPoint(distance);
}
}
}
and here is the code attached to the object I want to follow:
function Update () {
transform.position.x = StaticVar.PosX; //this is calling posx etc
transform.position.y = StaticVar.PosY;
transform.position.z = StaticVar.PosZ;
}
This code works, but there is a slight delay for the other object to catch up (very small, but noticeable). If I drag the object fast enough, I can actually get them to overlap. I want them to appear more solid though as if they were a single object.
I understand there will always be delay, but could anyone suggest an alternative to make it update a bit faster to appear more solid and move as one object rather than two?