- Home /
Unity Object Aligment in Different Resolutions and Scales
Hi guys, I am working on simple graphical programming application for kids.
I want to drag and drop blocks and attach them with nodes on the edges llike the image below;

There are two nodes input and output with box colliders. Dragging and matching works perfectly at 1920x1080 resolution and normal scale. But if I change the scale of blocks or change the resolution they are not matching correctly.
  private void OnTriggerStay2D(Collider2D collision)
     {
         if ((collision.tag == "Output" && gameObject.tag == "Input"))
         {
             Debug.Log("Stay");
             Vector3 targetPos = collision.gameObject.transform.position;
        
             if (Input.GetMouseButtonUp(0))
             {
                 offSet = transform.localPosition; // Input Node Position
                 Debug.Log("Locked");
                 gameObject.tag = "Locked";
                 collision.gameObject.tag = "Locked";
                 //GetComponentInParent<DragHandler>().enabled = false;
                 //  transform.position = targetPos;
                 transform.parent.position = targetPos - offSet; // parent pos = target pos - child local pos
             }
         }
     }
There is a collider part of the code which handles collisions on the joints. When Output Collider of the green block collides with Input Collider of the blue block , I am transforming blue block to target position relative to it is child. For clarify my hierarchy and structure; 
I really would be appriciate help :)
Your answer
 
 
             Follow this Question
Related Questions
How to transform position of object A to object C (C is a child of B object) 1 Answer
How Do I Give Two Objects the Same Transform? 1 Answer
How to transform children of an object? 1 Answer
Use transform.position in FixedUpdate to ensure collision with objects which have Velocity 0 Answers
How to have child object only follow parent x position 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                