Forum rules - please read before posting.

Layer Problems

I've just added my own sprite to the 2D demo and have spent some time getting it to work properly, but there's a couple of things I'm confused and stumped with. For some reason, the character always appears at the bottom of the screen even if the player starting position and off-scene arrows are in the same place for Brain. I have to literally move them so they're just above the hill in the background for my sprite to come onto the scene in the right position. My character is smaller than Brain, too.
The other issue is that my character keeps walking through the bird NPC no matter where they stand. It sometimes happens with the tree, even if I adjust the Sorting Map. The Sorting Map has to be really squashed down or the top one has to be pushed further up. Will I need to create another one just for the bird as well?

Comments

  • So your new sprite is a new player character?

    Make sure that the sprite child has a local position of (0,0,0) - you'll get a warning in the Console at runtime if it isn't.  Also make sure that the pivot point of the sprite itself is at the bottom, by their feet.  You can view the Brain sprite Inspectors for reference.

    The Sorting Map has no effect on character evasion / pathfinding.  Make sure that the Bird NPC has a Circle Collider 2D on them and that your Default NavMesh has "Character evasion" enabled.

    If you need more help, please post images so that we can see exactly what's going on.
  • For some reason, my sprite doesn't have an outer box like the Brain character does and therefore they have no pivot point. Not sure what's going on there. I have two Unity windows open - one with Brain and the bird, the other with my character and the bird. The one with Brain and the bird both have pivot points, but the one with my character, neither has a box around them with a pivot point. o_O
    The bird NPC has a Circle Collider 2D and I've even tried increasing it, but it doesn't make much difference - my character still clips through it if I click around it. The Default NavMesh has Only Stationary Characters selected for the Character Evasion.
  • edited April 2018
    Couple of screen grabs... And I did try setting the local position to 0,0,0 as well.
    https://imgur.com/a/tHV6A
  • The screens don't show much to go on.  What of the sprite's Inspector?

    You say that the sprite doesn't have an "outer box" - I don't know what exactly you mean by that, but if you don't have a pivot point then that's likely the cause.  The importing and configuring of sprites is all on the Unity side of things, not specifically to do with AC.

    Does the character evasion work correctly when Brain is used?  If so, the issue will be with your own character - in which case, please share screens of their full Inspector: both the root object and the sprite child.
  • Okay, my mistake - the box I was referring to is what appears when the Rect Tool is selected. The pivot point shows for my character, but clicking the Pivot option doesn't change its position. It should switch between the bottom or the centre, but with my character it stays in the centre. :-\
    Brain's evasion works perfectly, yeah. I've attached a couple of screens with the Inspector. As an aside, I've started working on my character's animation in Blender instead...
    https://imgur.com/a/fLQYX

  • That it's made in Blender won't be the cause.

    The sprite child's local position is non-zero, but (-2.97,0,0) - though perhaps that was to illustrate the sprite for the purposes of the screenshot.  Regardless, it's clear that the sprite's pivot is in the centre, not at the feet.

    I'm not sure why the Pivot can't be changed - you're clicking "Apply" afterwards to save the change?  Again, this is an issue with Unity / the sprite's import settings - but if you want to post a shot of the sprite asset's Inspector I can see if anything looks wrong.
  • edited April 2018
    These particular sprites were animated using After Effects and rendered as a PNG sequence. Could that be why?

    I'm not getting an Apply button when I change the Pivot. Okay, I've sorted out the pivot on all the sprites. I selected all of the frames for each animation, went to the Inspector and changed the Pivot from there to bottom. I re-did all the animations and my character is now appearing in the right place at the start. :)

    Just need to sort out the clipping problem now. My character is avoiding the Bird better, but they're still going through the tree. I've tried deleting my NavMesh and Tree Base and re-created them, but it hasn't helped much. If I drag the TreeBase game object into the Hole box, it causes the clipping. If I don't add it, my character is going round the tree better, but they occasionally get stuck and their animation keeps going.
  • Again, does this occur when Brain is the character?  I'd recommend keeping things as they are if it works with him.

    By clipping, you mean the sprites are not correctly showing in the correct order?  That's not to do with any NavMesh, but the SortingMap / FollowSortingMap components - which control the "Order in Layer" value of your character's Sprite Renderer as he/she moves around the scene.

    If Brain works OK, take a note of his order value at each point in the scene, and compare it with your own character's.  What's the difference?
  • No, it doesn't occur with Brain. I'll have to have another look at it tonight and try and match everything. I had a little go with that last night as well.

    My character sprite is still walking and standing in the tree, so yeah I think it's the SortingMap. I think I tried using the same properties as Brain, but will have another look tonight.
  • I think I've fixed it! On closer inspection, the position of my character as they walk was completely off. Compared to the idle position, the whole walking sprite looked like it was elevated. Correcting it seems to have fixed it. :D

    Thanks for all your help!
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.