Forum rules - please read before posting.

Adventure Creator applying a weird transform to NPC sprites

Howdy. I'm building a simple 2D scene with a navigation mesh, a player, and an npc. I've set the anchor for the player and npc sprites to the bottom middle, and set the sprite positions to (0, 0, 0).

At runtime, this works just as expected for the player, but the npc is misbehaving. Some seemingly arbitrary transformation is being applied to the sprite, setting its position to (-1.28, -3.16, 0). Even if I try to change this by switching back to the Scene tab and editing the value directly, it changes back instantly. By contrast, I am able to edit the scale in this manner without the change being overwritten.

Bottom line - is the engine applying a position transformation to the sprite within a 2D npc? If so, what is the intention behind it and can it be turned off?

Thank you to anyone who can help.

Comments

  • I'll need a bit more before I can advise.  What 2D mode are you in?  This is the "Moving and turning" field in your Settings Manager - by default this should be Unity 2D.

    Is it that the sprite child is being affected, while the "root" gameObject (with the NPC script) is in the correct place?  It may be that this is a Sorting Map issue - if you have a FollowSortingMap applied to the NPC, disable it and see if that solves the issue.  That won't be the solution, of course, but it'll help locate the source of the problem.
  • Thanks for getting back.
    It is indeed set to 'Unity 2D', and unfortunately the problem still occurs even with 'Follow Sorting Map?' turned off for that sprite.The position of the NPC's "root" game object changes slightly at runtime, but only by a fraction of the unit. It's the sprite that's way off.
  • If the Sorting Map is disabled, I can't see why it'd be affected at all, in that case.  Would you mind posting screenshots of your NPC's root and sprite inspectors, both during gameplay and not?
  • Sorry for the delay - I took the weekend off. Here are the captures. As you can see, the Sorting Map component is disabled, and the sprite's position at runtime shifts to seemingly arbitrary values.

    Before runtime, NPC
    image
    Before Runtime, Sprite
    image
    Runtime, NPC
    image
    Runtime, Sprite
    image
  • It may be because your Circle Collider is disabled.  Try enabling it and retrying.

    Another thing to try: re-enable (or just remove completely) the Follow Sorting Map component, but disable the "Follow Sorting map?" checkbox beneath it.
  • Unfortunately those are among the many permutations I've tried. I tried them again, just to be sure - no luck. I could speak to the project owner about sharing the source if this is too tricky to solve from afar? And of course if that's not too imposing, as I know I've taken a decent piece of your time already.
  • He agreed that it would be acceptable to share with you, so it's up to you. Thanks if you're able!
  • I'm happy to look at a project that can demonstrate the problem, but it must be reduced to the bare minimum needed to show it.  Make a copy of the project, remove all scenes / assets that are unnecessary and take up space, and them PM me.
  • edited June 2016
    Hi ChrisIceBox

    Did you Crack this issue? I am facing similar problem to this, my NPC is facing down left by default but when I play, he changes facing angle for no reason, I really don't know why?

    Thanks in advance!!!
  • I don't recall an issue from two years ago, no.  Please post a new thread providing full details and screenshots - it would be pure guesswork to advise otherwise.
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.