Forum rules - please read before posting.

Switch between SortingMaps

Hello friends, I have a problem, I want to use different SortingMaps for different positions of my player on the screen, I am looking but I cannot find the way to do it.
I have thought about placing a Collider and when it detects that the player enters it, change the SortingMap, and when leaving it, return to Default.
Is there any way from AC or any Script to do that?

Greetings and thank you.

Comments

  • edited December 2020

    Hello again, it took me a short time to find a solution, I used this script to be able to change between SortingMaps:

    public SortingMap NameSortingMap;
    public SortingMap Default;

    void OnTriggerEnter2D (Collider2D collider)
    {
    KickStarter.player.followSortingMap.SetSortingMap (NameSortingMap);
    }
    void OnTriggerExit2D (Collider2D collider)
    {
    KickStarter.player.followSortingMap.SetSortingMap (Default);
    }

    Besides I had to make a small modification in the Char.cs file
    I have changed the variable "Private FollowSortingMap followSortingMap;" to public.

    Now it works as I intended and I hope it helps you if you have the need to use the SortingMaps change.

    A greeting.

  • Welcome to the community, @Ciclope3160.

    It's not necessary to do this through code, or change the API: the Character: Change rendering Action can be use to change a sprite-based character's Sorting Map.

  • Thanks for the information, but how do I activate a list of actions when entering a collider?

  • edited December 2020

    Solved

    public ActionListAsset actionList;

    actionList.RunFromIndex (0);

    Thanks

  • how do I activate a list of actions when entering a collider?

    The built-in way is to rely on a Trigger - see the list of Logic prefabs in the Scene Manager. A tutorial can be found here.

    As you've found, though, both ActionLists and ActionList assets can be run through scripting. This is best done by calling the Interact() method. See the Manual's "Interaction scripting" chapter for details on the most common ActionList functions.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.