Forum rules - please read before posting.

Mouse drawing of a navigation mesh

edited February 15 in Technical Q&A

I came up with an idea in generating navigation meshes for my 2.5D game so I post it here, perhaps it is useful to someone or it's flawed :) Credits: I got help from ChatGPT in building it. The idea is to use the mouse to draw where a path mesh should be. Later on I will use some OpenCV contour mechanism to generate it without drawing, I believe.

I uploaded it here if anyone wants to use it.

Steps:

  1. Create a new 2D (non URP) project
  2. In assets, paste the files of the image you want to work with and the three scripts (one for the mouse drawing, one for extracting the mesh and one for saving it locally).
  3. Create object -> UI -> Image -> name it "Background" -> Drag the jpg to the Source Image and fit it to the main camera
  4. Add another UI -> Raw Image -> name it "Drawing Canvas" -> Below the "Background" object and fit it as well.
  5. Add another empty game object.
  6. Make sure "Both" is there for input modes in Project Settings.

Then:

  • In the "drawing canvas" object, add the "Mouse Drawing" script component and as "Drawing Canvas" add the Drawing Canvas Raw Image.
  • In the game object, add the "Navigation Mesh" script component and as "Drawing Script" select the Mouse Drawing

Then:

Run the scene. Draw with your mouse where the path should be. Press space and (check the logs) an new asset output.asset is created in your assets which you can then import to AC's NavMesh.

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.