Forums › 💬 NodeCanvas › 🗨️ General Discussion › 2d compatibility/unity 2d
Will nodeCanvas work in Unity 2D? Any help is greatly appreciated.
Hello,
Yes, NodeCanvas works fine with Unity2D and there are even actions/conditions included related to Unity2D.
Let me know if you have any other questions.
Thanks
I am really enjoying nodeCanvas! I need help with a navmesh for 2D. I cannot get the AI sprites to moveTowards or findTarget.
Hello,
Thanks! Unfortunately, Unity’s native NavMesh system does not support 2D games. There is nothing I can really do to make the native NavMesh work with 2D games cause it’s totaly up to Unity’s implementation. You will probably need to get a plugin for 2D pathfinding from the asset store for that, like for example PolyNav: http://u3d.as/6n3 which is also supported by NodeCanvas. (sorry for the shameless promotion :))
Once again, it’s simply a restriction of Unity, unless I misunderstood the question completely.
Let me know,
Thanks!
I figured that was going to be the solution. NavMesh 2D has depreciated. I will definitely check out the asset. Thank you for the support. I think a string/discussion about 2D might help someone in the community. I find nodeCanvas extremely useful in my game design and structure. I have been developing in Unity for three years and I feel like since I have been using nodeCanvas, my game structure is much more professional and fine tuned.Kudos. I am learning more and more everyday in the manual.
Thank you very much!
I am very glad to hear that you find NodeCanvas usefull in your projects 🙂
Comments like yours really keep the project going.
Thanks again
I did purchase the PolyNav asset. It works as expected, and better. This has really opened up many options for my design. I truly believe that any serious developer can benefit from the prototyping and getting right on the first or second try. Kudos!
Thank you!
I am really glad you enjoy PolyNav 🙂 Thanks!
Hello,
Is there a way to flip( or face direction) the sprite or Poly Nav Agent to look at object Player? Thank You.
Hello,
Here is a script to do that. I’ve added more cases so you can do extra stuff when the direction change. Just add it on your sprite gameobject and set the PolyNavAgent reference.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
using UnityEngine; using System.Collections; public class Flipper : MonoBehaviour { public PolyNavAgent agent; private Vector2 lastDir; private float originalScaleX; void Awake(){ originalScaleX = transform.localScale.x; } void Update() { var dir = agent.movingDirection; var x = Mathf.Round(dir.x); var y = Mathf.Round(dir.y); y = Mathf.Abs(y) == Mathf.Abs(x)? 0 : y; dir = new Vector2(x, y); if (dir != lastDir){ if (dir == Vector2.zero){ Debug.Log("IDLE"); } if (dir.x == 1){ Debug.Log("RIGHT"); var scale = transform.localScale; scale.x = originalScaleX; transform.localScale = scale; } if (dir.x == -1){ Debug.Log("LEFT"); var scale = transform.localScale; scale.x = -originalScaleX; transform.localScale = scale; } if (dir.y == 1){ Debug.Log("UP"); } if (dir.y == -1){ Debug.Log("DOWN"); } lastDir = dir; } } } |
Let me know if this works for you.
Cheers!
Yes, this code did the trick, very cleanly. Your support is spot on. I thank you for your time.
You are very welcome 🙂
Thanks as well!
