- Home /
How to add script to objects through Empty Child? (or other easier ways)
Hey guys. I'm a beginner to unity and while making my game I got stuck on one part. I have a few object spheres and cubes in a empty child and i want to rotate/spin them all together. Rather than adding individual scripts to each of them, is it possible to add a script to empty child or is there a better solution altogether. Thank you.,
Answer by Klarzahs · Oct 06, 2020 at 03:42 PM
Hi @Pantaa001
that mostly depends if you want to spin them around a common pivot/center, or each around themselves.
Common center: Use a parent empty gameobject, add all your spehres/cubes, and rotate the parent. All child objects will be rotated with the parent GO, keeping their own offsets from the center
Individual centers: Use the script on each of the objects
Hope that helps
Answer by arvindchetu · Oct 08, 2020 at 01:02 PM
Hello @pantaa001 ,
You can create an another empty game object and create one master/global script which will have one list of Target game objects. Write a business logic to rotate a gameObject and assign all those empty objects in that list.
Hope that works!!
Your answer
Follow this Question
Related Questions
Trouble with adding value using FieldInfo.SetValue(this, int + int) 1 Answer
Enabling another script when entering a triggered plane (C#) -1 Answers
Why can't it find the item in game, but knows what it is in script? 1 Answer
killing a script from another 0 Answers
Shooting Script which don't works: 1 Answer