Obstacle avoidance in the canvas

Hey Unity folks,

I’m making a little arcade style game in Unity and it’s all totally in the canvas. I’d like to have some sprites moving around from one place to another, but I’d rather not script them manually so I’d like them to avoid obstacles on their own.

Does anyone know of a way to get something in the canvas to behave similarly to how they would in the game world?

Are you asking if you can use the physics system on a canvas? Are you asking if you can get sprites to move around without scripting them? I’m not sure I understand the question.

I guess I’m asking if there’s a way to get the physics system to work on the canvas, or something similar anyway. I’ve made games with agents that use Unity’s pathfinding in the gameworld, but in this new project everything is in the canvas. I’d like to have the agents move from A to B, avoiding panels that I’ve marked as static obstacles.

Does that make more sense?

Physics objects will behave normally on a canvas, just add 2D colliders and rigidbodys as needed. As far as I know unity doesn’t have any built in 2D pathfinding, you’ll have to make it yourself or use a 3rd party asset.

Is the nav mesh agent working in 2D?
I guess you will need a way to resize your UI components and your colliders attached to them in script, else, you will have trouble if your UI get scaled to match user’s resolution.

Looks like I can’t generate a navmesh that is vertical. Anything over 58 or so rotation and the navmesh doesn’t render.

Ah well - maybe obstacle avoidance is too much to expect for something living in the canvas.