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 /
This question was closed Feb 28, 2015 at 10:54 PM by meat5000 for the following reason:

Duplicate Question

avatar image
0
Question by SUPPEAR · Feb 28, 2015 at 09:18 PM · android2dgameobjectmobileduplicate

Duplication Problem. Please help.

Hello. I am fairly new to both Game Creation and Scripting. I had created a script that duplicated my set object. I also had another script that destroys the object when the player collides with the object. All goes well until the duplication part. When the object becomes duplicated it changes its name from "Apples" to "Apples(clone)" When it adds the "(clone) to the end it doesn't allow my destroy on collision script to work since the name isn't "Apples" This is the script using UnityEngine; using System.Collections;

public class DestroyApples : MonoBehaviour {

  void OnCollisionEnter2D (Collision2D col)
  {
      //Check collision name
      Debug.Log("collision name = " + col.gameObject.name);
      if(col.gameObject.name == "Apples")
      {
          Destroy(col.gameObject);
      }
  }

}

Is there a way it can be duplicated without the "(clone)" or a way that it allows the script to detect the object.

Also here is my script for the duplication part.

 #pragma strict
 var theObject:GameObject;
  var maxPosY:float = 25.0;
  var minPosY:float = 25.0;
  var minPosX:float = -2.55;
  var maxPosX:float = 2.44;
  var max = 22;
  
  function Start(){
      StartCoroutine(spawn());
  }
  
      function spawn() : IEnumerator {
          for (var i = 0; i < max; i++) {
              yield WaitForSeconds(5.0);
              var theNewPos= new Vector3 (Random.Range(minPosX,maxPosX),Random.Range(minPosY,maxPosY));
              var go : GameObject = Instantiate(theObject);
              go.transform.position = theNewPos;
          }
      }
  

Sorry if my writing is in poor condition. I am quite tired. If any questions pop up, please ask.

All help is very much appreciated. Thank you.

Comment
Add comment · Show 1
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 meat5000 ♦ · Feb 28, 2015 at 10:54 PM 0
Share

http://answers.unity3d.com/questions/912060/duplication-problem-1.html

1 Reply

  • Sort: 
avatar image
0

Answer by hexagonius · Feb 28, 2015 at 09:25 PM

After instantiating set go.name = "Apples";

Comment
Add comment · Show 2 · 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 SUPPEAR · Feb 28, 2015 at 10:35 PM 0
Share

Thank you so much! This has removed all the stress I had about that one problem. Again I say, thank you.

avatar image meat5000 ♦ · Feb 28, 2015 at 10:52 PM 0
Share

@Hexagonius, this is a duplicate question.

Add your answer to the other QA thread.

@SUPPEAR Please go through your previous questions and conclude them. You have many unfinished questions.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Expand object on touch? 1 Answer

Transform.LocalScale Script Problem. Please help. 2 Answers

Expand Object On Touch? Someone please help me 1 Answer

Collision On Specific Object= Destroy not working. 2 Answers

Scaling Script? 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