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 /
avatar image
0
Question by Jamal_Alkelani · Aug 13, 2017 at 08:54 AM · collisioncollider2dballgames

My Instantiated object is affected by the original one

Hello everyone, I'm making a simple block breaker game like Arkanoid everything is perfect except that In my game I've a magic block which duplicates the ball into 2 balls I've used Instantiate() method, it worked perfectly but I had a problem, which when I hit the original ball with the striker the Instantiated ball is also affected by the collision of the original ball with the striker, but not vise versa I don't know why,but that's weird.

my instantiate ball code:

 public void duplicateBalls()
     {
         
         float xPos = this.transform.position.x;
         float yPos = this.transform.position.y;
         var ballClone= Instantiate (GameObject.FindObjectOfType<BallMovementManager> (),new Vector3(xPos,yPos,0f),Quaternion.identity);
         ballClone.GetComponent<Rigidbody2D> ().velocity=new Vector2(3,10f);
         ballClone.tag = "Clone Ball";    //changing the tag of the clone ball in order to destroy it later
         ballsCount++;    //incrementing the total number of balls in the game
 
     }

http://imgur.com/wxN8naW

+My ball has a rididbody2D and a circular collider +My striker has only a box collider

thanks in advance.

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
0

Answer by as30050273 · Aug 13, 2017 at 09:03 AM

Hello! I think you need instantiate it with changing it's X cord a bit. Like that:

 GameObject ballObj = GameObject.FindObjectOfType<BallMovementManager>();
 
 //fill that with half of the width of your ball
 float xOffset = 1f;
 
 GameObject ballClone = Instantiate (ballObj, new Vector3(xPos + xOffset, yPos, 0f), Quaternion.identity) as GameObject;
Comment
Add comment · Show 7 · 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 Jamal_Alkelani · Aug 13, 2017 at 09:11 AM 0
Share

the same problem stills idk if you knew what I meant suppose that the original ball is colliding with the striker and the clone ball is at the middle of the screen then the two balls would be affected by the collision and they will go up.

avatar image as30050273 · Aug 13, 2017 at 09:32 AM 0
Share

So make striker's collider trigger

avatar image Jamal_Alkelani as30050273 · Aug 13, 2017 at 09:38 AM 0
Share

that would not be efficient ! the ball must collides the striker not triggering it

avatar image as30050273 Jamal_Alkelani · Aug 13, 2017 at 09:52 AM 0
Share

Could you give a screenshot? I think I dont understand you

Show more comments

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

107 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 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 do I enable collision? 0 Answers

Tilemap Collider 2D preventing objects from moving 2 Answers

How do I get collisions between Tilemap Collider 2d and a Kinematic Rigidbody 2d? 1 Answer

How do I stop characters from standing on top of each other 1 Answer

How do I create a partial 2D sprite collision during trigger? 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