Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 DLBit · Dec 27, 2015 at 10:59 AM · physics2dcollider2dcompound collider

Effectors not working with compound collider?

I have a problem with the Area Effector 2D and my compound colliders. The thing is that the effector is applying its force multiple times to the Rigidbody2D. So objects containing multiple colliders are effectively affected by much stronger forces. This behaviour seems kind of strange to me... Is there any way to tell the effector to apply its force once per rigidbody instead of once per collider? Thanks!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MelvMay · Dec 27, 2015 at 01:07 PM

Why is it strange; because it's not what you want? Have you looked at any of the properties and tried experimenting?

Try changing ForceTarget i.e. the target where the effector applies the force. You can set it to affect the collider or the rigid-body. Both have use-cases.

http://docs.unity3d.com/ScriptReference/AreaEffector2D.html

Comment
Add comment · 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
0

Answer by DLBit · Dec 28, 2015 at 12:04 PM

Why is it strange; because it's not what you want?

Exactly... :-) And it's not what the documentation tells me.
Don't know if I tried everything but I experimented with a lot of the properties and combinations of the composition of my objects affected by the effector.
ForceTarget tells something about where the force is applied not how often.
Manual:

The force target is the point on a target object where the effector applies any force.

Scripting Reference:

The target for where the effector applies any force.

If I have an Object with a single collider attached everything works fine. If I split the collider (e.g. two half sized boxes instead of the single one) the effector applies its force twice. The GameObject I want to use has a compound of four colliders. This means my object is affected by the force four times in a single FixedUpdate. That is my problem with Unity's AreaEffector2D and I don' know how to handle it.

Currently I implemented my own Area Effectors to handle this.

Comment
Add comment · Show 4 · 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 MelvMay ♦♦ · Dec 28, 2015 at 01:12 PM 0
Share

If you want the force applied once then set the target to Rigidbody2D (there is only ever one rigidbody). This won't produce rotational forces though as the force is always applied to the center of mass but if you don't want that then this will work.

When set to collider, the force you specify is applied to the center of the collider that is in contact (not all colliders on a RB will necessarily be in contact) and I can see how that might be a problem.

The only conceivable way to do this is during the fixed-update, the effector counts how many colliders on the RB are touching, find their common center-of-mass and apply the force there.

It's certainly a feature that could be added.

avatar image DLBit MelvMay ♦♦ · Dec 29, 2015 at 10:31 AM 0
Share

If you want the force applied once then set the target to Rigidbody2D (there is only ever one rigidbody).

Exactly this is the problem. What you describe is what should be, but it's not. There is the one and only Rigidbody2D but multiple colliders. Each collider of the compound triggers the AreaEffector2D which then generates as many forces as there are colliders. All the forces are then applied to the one Rigidbody2D resulting in a force with a magnitude of N times that force with N the number of the colliders in the compound.

Here is a $$anonymous$$imalistic sample.

It contains two objects, each with a single Rigidbody2D. One has a single collider attached and the other four of them, each one fourth in size. Both objects are located inside an AreaEffector2D which adds a force upwards. If the AreaEffector2D would work as expected, both objects should behave exactly the same. But they don't. Regardless to the settings in the AreaEffector2D (ForceTarget: Rigidbody/Collider) or the objects (Rigidbody2D, UseAuto$$anonymous$$ass: true/false). The object with the compound collider receives always a much larger force (in this case four times as large).

I have now implemented my own version of the effector which handles that correctly and does other magic besides this. I'm now happy with that. :-)

avatar image MelvMay ♦♦ DLBit · Mar 19, 2016 at 07:32 PM 0
Share

This has been fixed. It is under review and will be going into the release streams in the near future.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Is this a correct way to have multiple different compound colliders in one gameobject? 1 Answer

How to avoid Rigidbody collider from getting stuck between walls 1 Answer

Physics2D.IgnoreCollision not working! 0 Answers

Collider2D.GetContacts() Checking One Physics Step Behind 0 Answers

How to use OverlapCollider? 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