Search Unity

How to create a custom Effector2D

Discussion in 'Physics' started by Tainted_Lemon, Jan 5, 2021.

  1. Tainted_Lemon

    Tainted_Lemon

    Joined:
    Aug 25, 2013
    Posts:
    5
    Hi,

    I am currently working with a Tilemap and the PlatformEffector2D. I would like to create a situation where some GameObjects are able to move through platforms in one direction, and other GameObjects are able to move through the same platforms in a different direction.

    The current PlatformEffector2D does not allow multiple instances of the component to be added.

    This post here: https://forum.unity.com/threads/area-effector-2d-with-varying-force-strength.467482/#post-3042641 states you can write your own custom Effector, but I'm unsure how to proceed.

    I can't browse the code for the existing Effectors are they are in C++. I tried creating my own class which extended Effector2D, to try and understand how it might interact, but I cannot add this class to a GameObject as it gives the following error: "The script don't inherit a native class that can manage a script".

    Any help would be much appreciated.

    Cheers