Hi,
I have Object A and Object B. now i want to attached both the ojects. So i have make Object A as parent of Object B .But the problem is that if i move Object B then object A is not moving but if i move Object A then object B moves prefectly. So please any body help me ?
For Drag the object i am using bellow code:
void OnMouseDown ()
{
if (isEnable) {
screenPoint = Camera.main.WorldToScreenPoint (gameObject.transform.position);
offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
}
}
void OnMouseDrag ()
{
if (isEnable) {
Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint);
transform.position = curPosition;
}
}
Thanks
Yashesh.
↧