Unity2D: How to make an object pick up another object and carry it around?
I need a little help guys. I am brand new to Unity and developing my first 2D game.
In my game, I am trying to make a bird pick a stick from the ground in her beak, fly around with it still attached to her beak and put it down somewhere else. I am rotating the bird back and forth (z-axis). When the bird's beak touches the stick object on the ground the stick should automatically attach itself to the bird's beak. The bird currently flies (my only achievement so far :P), and it should also be able to fly around with the stick in her beak. And lastly, the bird should be able to place the stick in a predetermined place (building nest). So when putting the stick on this predetermined place the bird will rotate down (z-axis) making the stick touch this predetermined space which is when the stick should de-attach and place itself in this predetermined area.
I have been trying to figure out how to implement this "object sitting on the ground when touched attach itself to a specific point of another object" all day long and couldn't come up with a solution. Maybe I am overthinking this.
Any solutions, directions, pointers? Simple the better!
Answer by tormentoarmagedoom · Jun 26, 2018 at 08:45 AM
Good day.
You need to learn how collisions, Triggers and colliders works, to knwo when to "pick an object".
Then you only need to change its parenting. If you make the objectA child of objectB, when objectB moves, objectA moves with it.
ObjectA.transform.parent=ObjectB.transform;
Bye!
Your answer
![](https://koobas.hobune.stream/wayback/20220612165504im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity error DirectoryNotFoundException: Could not find a part of the path : 0 Answers
How do you make a character flip in Unity 2d 1 Answer
Why does my External Script Editor only say "Open by file extension" or "Visual Studio Installer"? 0 Answers
Cant double jump with grounded code,Being grounded and Double Jumping 0 Answers