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
0
Question by FindusNeuman · Feb 04, 2014 at 03:08 PM · 2dcollisionphysicscolliderchild

2D Collision not working! (child sprites colliders)

Hello!

This is my first problem that I cannot solve without making a thread, it is just very painful dealing with this..

So the problem is that I have a parent GameObject that is my main character. That gameobject is empty, and all of his sprite parts (arms, head, feet, etc.) is made childobjects of the main character. Because they all have individual movement (in animations) and collision, and I want my parent GameObject to handle animation, player controlling and etc.

The problem is that I have tried using 2D rigidbody and a rigidbody, but they do not work; physics and collision does not work correctly. So I followed a tutorial and made "my" own, which works great, BUT, it can only have one collider. It requiers a Box Collider in the parent gameobject of all the sprites, which is very bad. I want to use all parts' individual colliders together, not one big rectangle around my main character, the animations would not work correctly and my collision would suck.

Picture: alt text

All the small green boxes are the individual colliders of the sprites attached to "Bertil" our main character that is an empty gameobject.

This is my scripts: Scripts DL Link

dadadadadadadad.png (161.7 kB)
Comment
Add comment · Show 4
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 Ashish Dwivedi · Feb 04, 2014 at 03:24 PM 0
Share

$$anonymous$$ake sure that rigidbody is added to object having collider. And remember that 2D collider cann't collide with 3D collider.

avatar image FindusNeuman · Feb 05, 2014 at 11:19 AM 0
Share

Ok, thank you. I added a rigidbody 2D to the parent gameobject and the collision works now, but the gravity is not working. The character is slowly levitating upwards. How do I fix this? :) And how do I fix so that the character only collides with a certain collisionmask?

avatar image Ashish Dwivedi · Feb 05, 2014 at 12:47 PM 0
Share

Set the "gravity scale" property of rigidbody2D to 1 then gravity will work but if gravity scale is 0 then gravity will not work. $$anonymous$$ake sure that iskinematic box of rigidbody2D is unchecked in the inspector.

avatar image FindusNeuman · Feb 07, 2014 at 09:37 AM 0
Share

I have done all that, it still doesn't work! And can I fix so that it only collides with a certain collisionmask and not everything?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ashish Dwivedi · Feb 08, 2014 at 07:16 AM

Yes you can fix it so that it collides with a certain object. For this you need to use layer for each object and assign layer to objects and call "Physics2D.IgnoreLayerCollision(int layer1, int layer2, bool ignore = true)" this method by passing the index of layer and the bool according to what you want whether object under both the layer should collide or not. Like wise you can enable and disable collision between any number of objects or collider.

IgnoreLayerCollision reference

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 FindusNeuman · Feb 18, 2014 at 02:10 PM 0
Share

Thank you, the gravity and collision works now. But the collision kind of the character "stutters" when walking in to a wall or walking up a ramp. I can even if I push long enough into a wall get through it, how do I solve this?

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

20 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

Related Questions

How do I get the player and the object they touch both disappear/destroyed? 1 Answer

Prefab instantiated by code, collision does not work 0 Answers

Ignore collision at high velocity. 1 Answer

Best collision detection method? 2 Answers

Projectiles, their speed, and collisions 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