Search Unity

Effectors effecting objects it's not supposed to

Discussion in 'Physics' started by jsull1, May 28, 2018.

  1. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    I have an effector in my game and some objects that are supposed to move normally over it. The object is not selected as "used by effector" but is still clearly being effected by it. Anybody understand what is happening here?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    "used by effector" doesn't select which collider is affected, it's used to select a collider which is part of the effector i.e. an area used to apply forces to other bodies/colliders. Doubtless you've already got such a collider/effector combination set-up. To select what that effector applies its forces to you use either the standard collision layer matrix or you can select it specifically in the effector itself using the effector collider mask.

    https://docs.unity3d.com/ScriptReference/Effector2D-useColliderMask.html
    https://docs.unity3d.com/ScriptReference/Effector2D-colliderMask.html
     
    jsull1 likes this.
  3. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Okay I've put both the objects I'm dealing with on specific layers. Then I scripted into the moving object Physics2D.IgnoreLayerCollision (9, 10); Unfortunately this didn't do the trick, the effector is still effecting my object and now I can't see either object in my scene view.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Which "objects" are these? The effector collider and the "other" collider?

    You're changing the problem you originally described by adding this. I have no idea what the object layers in question are therefore what 9 and 10 are.

    If you have the "useColliderMask" turned off then effectors use the exact same collision layer matrix as everything else. Ignore the effector for a moment and just see if two objects set the same contact each other or not.

    I'll need more info to help you really otherwise I'm just guessing.
     
    Last edited: May 30, 2018
    jsull1 likes this.
  5. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Okay in my game the character is being pulled down a river and is being chased by alligators. The character should be effected by the rivers pull (area effector) but the alligator should not, because it’s causing a lot of issues with physics and I’d rather have it on a set path.
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    Sorry but by more info I meant describing the body/colliders you have set-up i.e. their layers etc.

    Maybe if you could create a simple reproduction case and send it to me I'd be happy to look at it.
     
    jsull1 likes this.
  7. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Okay when I get home from work I'll create a scene with just the objects involved. What's the best way to send something like that?
    Thank you!
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    You can upload your project here.
     
    jsull1 likes this.
  9. jsull1

    jsull1

    Joined:
    Apr 3, 2018
    Posts:
    121
    Oh sorry MelvMay, I forgot to respond, I fixed my problem by simply making them triggers instead. Thank you though I learned a lot about triggers.
     
    MelvMay likes this.
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,491
    No problem, all that matters is that you got it working. Good luck.