Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
1
Question by Afassolas · Feb 19, 2016 at 06:25 PM · 2dlists2d rotation2d array

How to select two 2D objects in order to make a third object

Friend developers I am in need of your help for a simple project I am working on. I have a collection of very simple 2d shapes like triangles and cubes. Please follow my image.

What I want is when the user clicks on object A and then on object B these objects to disappear and become one object C. After that I want the user to be able to click on another object of type A or B and object C so that these two objects disappear and become object D. This could go on indefinitely

I am stuck on how to go about this and I appreciate your help and time!

alt text

This is what I have so far

 public class Selector : MonoBehaviour {
     public string FirstSelection;
     public string SecondSelection;
     public  int SelectionNum;
     
     // Use this for initialization
     void Start () {
         SelectionNum = 0; 
 
     }
 
     void OnMouseDown()
     {
         SelectionNum += 1; //selection counter
 
 
         Debug.Log("Selection " + SelectionNum);
 
         if (SelectionNum == 1) //if this is the first selection
         {
             FirstSelection = gameObject.name; //assign the name of game object clicked
             Debug.Log("First " + FirstSelection);
         }
 
         if (SelectionNum == 2) // if this is the second selection
         {
             SecondSelection = gameObject.name; //assign the name of game object clicked
             Debug.Log("Second " + SecondSelection);
         }
 
         // Combinations of A + A or B + A will destroy A and B gamebojects 
         if (FirstSelection == "A" & SecondSelection == "A" || FirstSelection == "B" & SecondSelection == "A")
 
             {
            
             
             Destroy(GameObject.Find("A"));
             Destroy(GameObject.Find("B"));
 
             // Instantiate game object C (not there yet)
 
         }
             
             
         
     }
     
     
     
     // Update is called once per frame
     void Update () {
     
     }
 }
 


stick.jpg (76.0 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
-1

Answer by Aparant · Mar 14, 2016 at 02:22 PM

Create an empty GameObject and assign the selected Gameobjects as child to the empty gameObjects.

Comment
Add comment · Show 1 · 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 Afassolas · Mar 15, 2016 at 08:10 AM 0
Share

this does not help man

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

68 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I make player shoot in 2d with a joystick when we move the joystick out of its circuler area 0 Answers

Detect a Full 360 input on a joystick 1 Answer

Player rotation 2d 0 Answers

The size of the object changes when rotation 0 Answers

Factorio-like sprite directions 0 Answers


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