Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by hrlarsen · Nov 21, 2012 at 11:18 AM · gameobjecteditortransform

Can you mirror a bunch of gameobjects ?

Hi all

I suddenly would like the ability to mirror a bunch of gameobjects, in my case with colliders attached.

any ideas?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hrlarsen · Nov 21, 2012 at 11:34 AM 0
Share

In reality it is because I made some colliders manually for a rounded pair of stairs, and just want to copy those colliders to the other side. I tried scaling the colliders in a negative direction, but didn't work, so I guess I just have to do it manually again :)

avatar image Fattie · Nov 21, 2012 at 11:45 AM 0
Share

sigh it's really confusing when people post questions, and it turns out the question is utterly and totally unrelated to what it sounds like the question is about

avatar image hrlarsen · Nov 21, 2012 at 11:48 AM 0
Share

I guess sometimes it is just hard to put the questions right.. my bad, edited the question

2 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by Kmulla · Nov 21, 2012 at 11:44 AM

Hi Jake :)

It's possible to just set all the scale values to -1 and then rotate your gameobject in the desired axis by 180 degrees.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hrlarsen · Nov 21, 2012 at 11:46 AM 0
Share

Thanks $$anonymous$$mulla... that one worked! I guess I just didn't see it from the beginning

avatar image Nakor · Mar 21, 2014 at 03:34 PM 0
Share

Wow. Thank you. I have been using Unity a long time now and I NEVER ONCE even thought of that. Crazy how obvious it seems now.

avatar image roryo · Jan 17, 2016 at 10:47 PM 0
Share

Wow - this is an amazing solution and saved me from a huge headache! Thanks, $$anonymous$$mulla!

avatar image Mayhem-McAwesome · Dec 23, 2019 at 11:15 PM 0
Share

Thank you! This solved a problem that would've had me stumped for hours, if not days!

It has a huge advantage over simply flipping the desired axis, that it does not mess up future transform operations done by the mirrored object!

avatar image
0

Answer by toomasio · Jan 30, 2018 at 09:21 PM

Here's one way to mirror objects without adjusting the scale. You can use the public method to switch the master objects that you wish to manipulate.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class MirrorGameObjects : MonoBehaviour
 {
 
     public List <Transform> objsToMirror = new List<Transform>();
     public Transform slaveParent;
 
     private Transform[] masterObjs;
     private Transform[] slaveObjs;
 
     // Use this for initialization
     void Start ()
     {
         CreateSlaves();
     }
     
     // Update is called once per frame
     void FixedUpdate ()
     {
         MirrorObjects();
     }
 
     void CreateSlaves()
     {
         if (!slaveParent)
             slaveParent = transform;
         if (objsToMirror.Count < 1)
         {
             foreach (Transform child in transform)
             {
                 objsToMirror.Add(child);
             }
         }
             
         masterObjs = objsToMirror.ToArray();
         slaveObjs = new Transform[masterObjs.Length];
         for (int i = 0; i < objsToMirror.Count; i++)
         {
             slaveObjs[i] = Instantiate(masterObjs[i]);
             slaveObjs[i].SetParent(slaveParent);
         }
         
     }
 
     void MirrorObjects()
     {
         for (int i = 0; i < objsToMirror.Count; i++)
         {
             slaveObjs[i].localPosition = new Vector3(-masterObjs[i].localPosition.x, masterObjs[i].localPosition.y, masterObjs[i].localPosition.z);
             slaveObjs[i].localEulerAngles = new Vector3(masterObjs[i].localEulerAngles.x, -masterObjs[i].localEulerAngles.y, -masterObjs[i].localEulerAngles.z);
         }
     }
 
     public void SwitchMaster()
     {
         Transform[] temp = masterObjs;
         masterObjs = slaveObjs;
         slaveObjs = temp;
     }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

uGUI WorldSpace elements part of GameObjects 0 Answers

selecting and organising objects in editor 0 Answers

Fold/unfold gameobject from code 4 Answers

Keep adding targets to a list 2 Answers

Rotating a Vector3 in Instantiation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges