- Home /
Question by
Futtureman · Aug 19, 2017 at 10:12 AM ·
uicanvascollider2dtransform.positionui image
Transform translate not working properly in Canvas
private void OnTriggerEnter2D(Collider2D collision)
{
collision.gameObject.transform.SetParent(transform);
collision.GetComponent<DragHandler>().enabled = false;
collision.gameObject.transform.Translate(transform.position);
}
I want to set collided object's position to base object's position. But collided object's position not set properly in canvas.
wrong.png
(55.8 kB)
Comment
Translate offsets a transform by the given vector. What you need to do is just setting the localPosition to Vector3.zero