Forum rules - please read before posting.

SortingMap not working

Hello there, I just recently bought AC & am following the tutorial here & running into issues along the way. I've used Unity a bit before so thankfully I've been able to figure most of the stuff out, but right now I'm running into a problem where the Default SortingMap is not layering my PlayerSprite correctly when running the game. 
I'm using the 2D demo assets (with my own player sprites) & the character won't go in front of the tree at all. I triple checked all the settings & everything seems to be set up properly, according to the tutorial. The only thing I can think of for why it's not working is that I'm using my own custom player sprites, which are just png sequences for and idle & a walk animation. Any help is appreciated. 

Comments

  • edited October 2018
    Welcome to the community, @siskavard.

    An easy way to check if the problem lies with your player or some other setting is to drop the 2D demo game's player, Brain2D, into your scene and run the game.

    He can be found in /Assets/AdventureCreator/2D Demo/Resources.  A Player present in the scene file will override the prefab defined in your Settings Manager, so you can use this to temporarily test out how he behaves.

    If he works OK, the issue is likely with your own Player.  In which case, let's have a look at some screenshots of your own Player's Inspectors (both the root object and the sprite child).  Also check that the sprite child's local position is (0,0,0).

    If not, the issue is likely with your scene - so let's see the Scene Manager, the Sorting Map itself (both its Inspector and the Scene view), and the Inspector of the Tree.

    Are you getting any relevant messages in the Console?  Please also let me know your AC and Unity version numbers.
  • I tested Brain2D & he does in fact layer properly in front of the tree. My sprite's child postion was NOT set to 0,0,0 & when i set it to that, it seems to want to layer properly but not quite - I'll post a gif as well as some screenshots from my player object:


    image


    imageimageimage
  • Turn pivot of your sprite to Bottom:
    https://imgur.com/sznUYDw
  • Thanks disya75, that seems to have fixed the issue for the most part, however now the player seems to be ignoring the 'hole' in the navmesh meant for the tree base - he just walks right over top of the tree.

    Also I forgot to mention I'm using AC# 1.65.1 & Unity 2018.2.13f1 Personal

    imageimage
  • Your sprites must indeed pivot around their feet - see the Manual's "Character animation (Sprites Unity)" chapter for more.

    About the NavMesh hole: does the NavMesh itself integrate the shape of the hole successfully?  You can check this by moving it around in the Scene window at runtime - it should incorporate the hole into its own shape, even if you disable the hole gameobject at that moment.

    Again, see if Brain2D has the same issue.  It does look like the hole comes too close to the upper edge of the NavMesh, however.  Try moving those two upper vertices on the hole down so that the gap above it is wider.
  • It's working now & I think I've figured out something about my project - I've been working on it from two different PC's via Dropbox. I've learned that Dropbox has a tendency to screw Unity projects up. I was seeing issues on one PC that I wasn't seeing on another. 

    I wanted to use DB because I've been using it for years, but I think I have to bite the bullet & use Git. I really, really, really hat using git but I think I have to do it, haha.

    Thanks for the help Chris & everyone & Disya. I'm sure I'll be back very soon with more questions.
  • I don't know what I did, but after setting my Unity file up for version tracking on Git, some stuff went out of whack when I next opened my file. The navmesh seems to be off even though it's showing up in the right place in my scene window? image
  • edited October 2018
    It looks like the pivot point of the sprite has reverted back to its centre.  See the "speaker" icon in the GIF: that's the AudioSource component on your character's root.

    The pathfinding itself appears correct - assuming the root object is where the speaker icon is, the blue line correctly points to the correct destination point on the NavMesh.  It doesn't go beyond the boundary of the NavMesh, so that at least seems OK.

    The NavMesh hole, however, has again been removed.  Perhaps there was a loss of data after removing Dropbox from the equation.
  • The Navmesh hole is indeed still there:
    image


    ..and i've set all my player sprite pivots to bottom:

    image
    .. I think Unity doesn't like me XD
  • The hole is configured in the NavMesh Inspector, and the player's sprite child is at (0,0,0)?

    Best to see this for myself - don't worry, we'll get this sorted out.  If you can PM me your project, I'll take a look what's wrong.

    To do that, select the Assets window in your Project window and choose Assets -> Export package... from the top toolbar.  So long as you haven't edited or added to the files in the AdventureCreator subfolder, you can uncheck that and leave it out of the .unitypackage file it then creates.  PM it to me and I'll see what I can do.
  • AH! My Sprite child was NOT set to 0,0,0 - that fixed it. Thank you so much. 

    I'm going to continue with the tutorial - but I'm curious - is there a way to reuse my character's walking & animation for both directions, rather than importing mirrored sprites of the same animation?
  • Yes - there's a "Frame flipping" option in the Player's Inspector.

    A full rundown of all animation options can be found in the Manual's "Character animation" chapter.
  • Thanks Chris - I haven't cracked that manual open yet, just jumped straight into the tutorial video. I'll jump in there & take a look. 
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.