- Home /
Drag multiple gameobjects ?
hi , i have multiple cards in the hand (panel in canvas) , and i can drag any card using (IBeginDragHandler, IDragHandler, IEndDragHandler) , my question is ... how can i drag multiple cards (more than 3 go) at the same time ?
perhaps have a container object with your IDragHandler etc on it. Then when you 'select' a card or multiple, add them as children to the container object, and controll the drag from there.
Answer by aWolfKing · Apr 30, 2016 at 08:14 PM
If you change an gameobjects parent it will be in that 'localspace', so if you move the parent all child objects will move to, because their position will stay the same within that localspace.
public GameObject Container = new GameObject("Container");
public GameObject CardOrGameObject;
//moving card or gameobject into container:
CardOrGameObject.transform.parent = Container; //CardOrGameObject is now a child of Container.
//removing from container: just change parent again
Your answer
![](https://koobas.hobune.stream/wayback/20220612075921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
UI Image source image not changing 2 Answers
How to make my cards dragable in my solitaire game? 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer