I am attempting to make a top down 2D shooter with sprites, and need help getting everything to work correctly. My game will need pathfinding for its AI, and to accomplish this I am trying to use the Nav Mesh Agent. Doing this with Unity’s 2D perspective appears to be impossible, since the Nav Mesh won’t bake on a plane parallel to the Y axis. What I am trying to do instead is have a fixed top-down camera on the Y axis, and have my Game take place entirely on the X and Z axis(depicted in my pictures). This way I can bake a NavMesh and use the Nav Mesh Agent for my AI.
To accomplish this I am using a GameObject with a box collider, a sprite renderer, and a NavMeshAgent
Unfortunately I am not getting the desired results.
Prior to playing the scene, it looks like this. Everything is the way it should be.
When I play the scene, the sprite, and it’s collider rotate perpendicularly to the ground, looking like this.
Pathfinding behaves the way I intended it to by my script, but I don’t want the NavMeshAgent to rotate my sprite renderer.
Can anyone tell me how to stop the NavMeshAgent from rotating my GameObject, so that my sprite stays at the desired perspective.
I have tried manually setting the GameObject’s rotation, and that doesn’t seem to work. I have also tried using this line of code in my script…
GetComponent().updateRotation = false;
…and that doesn’t seem to work either. Are there any suggestions? The game I’m making needs to be made in a crunch, so programming my own pathfinding isn’t really an option, and I really want to pathfind through the NavMeshAgent since that’s what I’m familiar with.