Is it possible to use a Nav Mesh Agent in a 2D game? For now, my game is in x-y axis, but NavMeshAgent's height is on axis Y, so not in a way my game is. Is there any way to change axes of this component? Maybe there is another way to make it work (because for now, it doen't work at all)?
Currently NavMesh can't be used on the XY plane (but this feature is coming). If you really want, you can rotate sprites to be on the XZ plane and point your camera down.
Thank you for reply! Can you tell me where to find how to do this? Also, is there something similar to NavMesh, but for 2D enviroment?
I don't know of any 3rd party assets to do this. But do check out these videos: perhaps that is enough for your project?
For now, I have a problem to change my PlayerMobility.cs script so the Player go horizontally on axis X and vertically on axis Z (previously the vertical movement was on axis Y). I don't know what should I change in a script. Can you help me? Code (CSharp): using UnityEngine; using System.Collections; public class PlayerMobility : MonoBehaviour { public float speed; // Normal Movements Variables private float walkSpeed; private float curSpeed; private float maxSpeed; private float sprintSpeed; private CharacterStat plStat; Animator anim; //chodzenie postaci void Start() { plStat = GetComponent<CharacterStat>(); walkSpeed = (float)(plStat.Speed + (plStat.Agility/5)); sprintSpeed = walkSpeed + (walkSpeed / 2); //koniec chodzenie postaci anim = GetComponent<Animator> (); } void Update() { if(Input.GetMouseButtonDown (0)){ anim.SetTrigger ("atak"); } } void FixedUpdate () { //ruch w kierunku myszki var mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition); Quaternion rot = Quaternion.LookRotation (transform.position - mousePosition, Vector3.forward); transform.rotation = rot; transform.eulerAngles = new Vector3(0,transform.eulerAngles.y,0); GetComponent<Rigidbody2D>().angularVelocity = 0; //koniec ruchu myszki //chodzenie postaci wsadem curSpeed = walkSpeed; maxSpeed = curSpeed; // Move senteces GetComponent<Rigidbody2D>().velocity = new Vector3(Mathf.Lerp(Input.GetAxis("Horizontal")* curSpeed, 0.8f,0), Mathf.Lerp(0.8f, 0, Input.GetAxis("Vertical")* curSpeed )); } }
Any eta on 2d navMesh ? Rotating to 90 degrees allows nav meshes in 2d or 3d project, but there are gazilion of issues, constantly resetting view if you have "maximise on play", landscape that becomes invisible to camera if it's set to "static" , controls doesn't work, making you switch to 3d objects for that z axis... and no collider navigation , I hope that is coming with 2d nav mesh?