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 ijskar · Apr 03, 2016 at 10:10 PM · collisionrigidbody2dboxcollider2d

I instantiated the individual pixels of a sprite as gameObjects, and gave them rigidbody2Ds and BoxCollider2Ds, when instantiating them, they 'explode' away from eachother.

I've been inspired by the following reddit post: https://www.reddit.com/r/Unity3D/comments/4cbw1g/made_a_screensaver_by_shooting_sprites_at_each/

I'm trying to achieve the same thing. So I've created a script that goes over a sprite, and reads each pixel's location and color. The sprite I'm using looks like this: alt text (The sprite is just 10x10 pixels big, hence the low resolution.)

Then, it instantiates a pixel-prefab, which I've made, on each of those locations, and gives it the same color as that pixel on the sprite has. The pixel-prefab is basically a 1x1 pixels white .png file which I've given a rigidbody2D and BoxCollider2D in Unity. I've made it so that it's not affected by gravity.

The problem is, that when I instantiate all these pixel-prefabs, they explode away from each other, as can be seen in the following .gif:

https://i.gyazo.com/5ba2f89708aae9b6e2985dc8eb31463c.gif

When I disable the BoxCollider2D component of the pixel-prefab, the problem ceases to exist. Giving the following result: https://i.gyazo.com/37c87abd2b90bc838c68766e6980d35d.png This is not a solution, since I'm trying to make the sprite, made out of multiple pixel-prefabs, to collide with another sprite, as can be seen in this gif: https://gfycat.com/DimpledFlippantCuckoo

So, basically, I don't want the sprite to fall apart prematurely.

Things I've tried are: 1) Put the pixel-prefabs of the first sprite on one layer, called layer1, and the pixel-prefabs of the second sprite on another layer, called layer2. Then I make Unity ignore collisions between layer1 and layer1, and between layer2 and itself as well, so that the pixels of the same sprite don't collide. This gives following result: https://gyazo.com/2cc52ff4926e564edb5419981c9c1cf3 This is not the result I'm looking for, since the pixels of the first sprite then just awkwardly fly through eachother.

2) Disable the BoxCollider2D of the pixel-prefab, and write a script that enables it when it comes close to the pixel-prefabs of the second sprite. This has as result that even on the slightest touch between the two sprites, the BoxColliders enable and the explosion takes place anyway. That is not a solution to the problem, it only delays the problem.

3) Shrink the BoxCollider2D-component of the pixel-prefab, so that it doesn't collide immediately once instantiated. The explosion still takes place, although I don't understand why this happens. So, still not a solution to the problem.

Anybody has any ideas?

466ba773210d9912effa5f6963761400.png (20.9 kB)
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 ♦ · Apr 03, 2016 at 10:09 PM 0
Share

You could simply make the rigidbodys kinematic until you are ready for them to explode.

Or perhaps have them ignore collision with each other.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2DColliders going through eachother 1 Answer

IsTrigger Effecting collision 1 Answer

Weird 2d collision behaviour 1 Answer

2D Pong Ball Not Reflecting Off Walls "Exactly" 1 Answer

Object passes through collider even when isTrigger is turned off. 2 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