Forum rules - please read before posting.

2D Mecanim Sprite Animation disappears when moving

The animation states are changing just fine using Mecanim, however the sprite object that has the animator on it is disappearing when moving. I have it set as the sprite transform on the root object. It only comes back if I rotate the sprite objects Y axis by 90 degrees like the root object does, but obviously can't imagine this would be default functionality. I have tried keeping the Sprite animator on the root object as recommended in the manual as well as using a separate child object, but the same thing happens with both. Rotation is 0,0,0 across the Sprite child at all times, so I'm unsure why it isn't normalizing with the root object.

Any recommendations or script adjustments? Something in the project settings that could cause this? I tried implementing a physics controller that used 3D physics, and it did end up changing some project settings when I imported. I can also provide screenshots if needed, but I'm pretty sure all the basic setup is correct.

Comments

  • Welcome to the community, @lsdsoftware.

    It sounds like you just need to uncheck Turn root object in 3D? in the Player's Inspector.

    If your sprite is a child object, and you've assigned it in the Sprite child Transform field, then the above option shouldn't matter - but it will need to be unchecked if the sprite is attached to the root.

  • Hey Chris,

    Thanks for getting back so quick, sorry I forgot to come back to this. I've switched over to Sprites Unity Complex and it seems to be a better fit for me overall, but I do want to point out that I didn't even see the option for Turn root object in 3D when I set a character to Mecanim. Just checked with a new character and same thing. Is that supposed to be there?

    Not directly related to my original post, but there are two other issues I've been having, related to navigation and collision. For one, colliders on the default layer won't prevent clicking in that area, which I understand they'e supposed too.

    Two, dealing with avoiding NPCs that have circle colliders, my player seems to be unable to path-find around them if they are ever outside of the NavMesh at any prior point. I have a barrel dropping from the sky, from an area I don't want my player to be able to walk in so the NavMesh doesn't extend there. When that Barrel falls and is within the Navmesh, my Player ignores its collider. It seems that this has an almost permanent effect? When I create a new NPC it will path-find around the circle collider, but then when I go into play mode and move the object to the marker from the desired origin spot, it will ignore the collider on all simulations going forward, even if it I just put it back to a stationary spot within the Navmesh.

    Any insights into these issues would be much appreciated! Let me know what you may need!

  • edited December 2023

    I didn't even see the option for Turn root object in 3D when I set a character to Mecanim. Just checked with a new character and same thing. Is that supposed to be there?

    The Mecanim option is intended for 3D characters - details of each option can be found in the Manual's "Character animation" chapter. For sprite-based characters (even if they are in a 3D game), you'll want to use either of the Sprites options.

    colliders on the default layer won't prevent clicking in that area, which I understand they'e supposed too.

    You're referring to clicks on the NavMesh? Not strictly.

    If a click isn't made on either a NavMesh or a Hotspot, AC will "search" around the cursor in screen-space for the nearest point on the NavMesh. You can configure this behaviour - or remove it completely - with the NavMesh search options in the Settings Manager's "Movement" panel.

    As it's a visual issue, share screenshots of the scene / settings if this isn't enough to resolve it and I'll take a look.

    dealing with avoiding NPCs that have circle colliders, my player seems to be unable to path-find around them if they are ever outside of the NavMesh at any prior point.

    NPC evasion is more of a means to avoid character-clipping than physically preventing the Player from moving somewhere. For that, you'll want to alter the NavMesh manually.

    What is your scene's "Pathfinding method" set to?

    For 2D scenes, you can either add in a NavMesh hole by creating a new Polygon Collider to represent its shape - or replace the NavMesh entirely with a second one that's been re-shaped to describe the blockage.

    The hole system involves updating the NavMesh's Polygon Collider with a new Path, so results may vary and is best used for carving out the NavMesh while still leaving the rest of the NavMesh accessible. If you want to block off access to a section of the NavMesh completely, either carve out this entire shape as a hole, or swap the NavMesh. Both of these can be done with the Scene: Change setting Action.

    I can advise further - but as this too is a visual problem, it'll be best so see screenshots to better understand the situation.

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.