Forum rules - please read before posting.

Beginner Problem - Making 2D Sprite Interact With NavMesh

I am currently making a 2D adventure game with static backgrounds and sprites. I've followed the 2D tutorial, and messed around on my own several times, but I can never get a player sprite to interact with the boundaries I set with a NavMesh. Instead, the player always just walks all over the screen like there are no boundaries whatsoever. I feel like I've tried and looked up everything, so I thought I would try looking here for answers. Any help would be appreciated. 

Comments

  • Welcome to the community, @BadDurandal.

    Without seeing some screenshots, I can only offer general advice at this point.  Check that your NavMesh is assigned as the Default NavMesh in the Scene Manager, and that your Pathfinding method is set to Polygon Collider.

    What are your AC and Unity versions?  Let's see some images of the scene, NavMesh, Scene Manager, and player when this occurs.

    It may be that this is an issue with your player, rather than the NavMesh.  To test this, drop in the 2D Demo's player prefab, Brain 2D, into the scene.  You can find him in /AdventureCreator/2D Demo/Resources.  Does he move correctly?  If so, the issue will be with your own player - in which case, we'll need to see how he compares to Brain.

    Also, how is your game scaled in comparison with the 2D Demo?  1 Unity unit should roughly equal 1 metre, so if you're very much smaller than that then you may have a situation where the player is considered "not too far" from the NavMesh to be off it because the positional values are very small.  See the top of the "Preparing a 2D scene" chapter in the Manual for more on this.
  • So I tried dropping the 2D demo character in and it still isn't working correctly. Both Unity and AC are up to date.


    The sprite and backgrounds are both very low-res, as I'm trying for a very grimy Gameboy-esque style. I have to scale both of them up when I put them in Unity. The background gets scaled up by 7 and the sprite by 4. Could that be the problem?


    Also, on the subject of sprites, I am unable to get them to animate properly. I've followed the tutorial instructions for setting an animation controller, but even when I'm trying to just make simple 3-frame downward walking animations, it doesn't work at all. I've even sliced the sprites in Unity's sprite editor, but for some reason they never displaying the Animation/Animator windows. Is there a specific file type I need to be using? I'm currently uploading most of the sprites as PNG files. image
    image
  • So I just realized that Ihad the control set to Direct instead of Point and Click. Upon changing it back, the Navmesh is now working correctly. Is there a way to make it work with Direct Control? I find it much more preferable than Point and Click.


    Also my animation conundrum still stands. Would you be able to help me with that here or should I break it out into another topic?
  • The 2D Demo's character is comparably sized with your scene, so the scale looks fine.

    Characters that move with Direct mode won't obey the NavMesh, as the NavMesh is used to determine pathfinding rather than collisions.

    You'll instead have to place down 2D colliders along the boundary of your walkable area to prevent the character (with a rigidbody and collider of his own) from passing through it.  The provided 3D Demo uses this technique (but using 3D colliders) to make the game playable in Direct movement as well.

    Regarding the animation issue, AC leverages Unity's animation tools so if you're new to Unity then you may need to watch Unity's own tutorials on animation to get to grips with it.  There is, however, a text-based tutorial on creating 2D characters here, and if you'd like to get more specific advice then you can post screenshots showing what you've got so far in a new thread.
  • Thank you so much for your help! I've been banging my head against these problems for days, and other forums have been pretty unhelpful.  I will give those fixes a try. 
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.