Search Unity

Question How to recognize the coverage in specific area by drawing stroke?

Discussion in 'Getting Started' started by CHUNG_WEN, Dec 5, 2022.

  1. CHUNG_WEN

    CHUNG_WEN

    Joined:
    Dec 5, 2022
    Posts:
    2
    Hi everyone,
    I am a junior game developer.

    Recently, I want to make a game to draw something in specific area.
    If the area is filled by stroke of drawing, it will show the icon of success.
    (The gray font is specific area. If the blue stroke fill this,the game will show icon.)

    I find the relational plug-ins in unity asset store.
    https://assetstore.unity.com/packag...-simple-drawing-on-sprites-2d-textures-113131

    But I don't know how to recognize the coverage in specific area by drawing stroke.

    Can anybody help me about this issue? Draw.png
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    how accurate it should be? like what if user leaves 1-2 pixel gaps to that line?

    some ideas to try
    - place invisible colliders inside that gray area, and then during drawing you "collect" them, and need to collect all of most of them to be complete
    - divide gray area into grid (larger than pixels), user need to visit enough grid cells
    - if its mesh shape, or mesh/polygon collider, maybe works if need to draw near enough each vertex ("mark each vertex position visited")
    - divide image to lines (horizontal and or vertical also), user needs to intersect each line
    upload_2022-12-5_10-5-24.png
     
    CHUNG_WEN likes this.
  3. CHUNG_WEN

    CHUNG_WEN

    Joined:
    Dec 5, 2022
    Posts:
    2
    mgear,I apperaciate your idea very much.
    I will try this method in my unity project.
    Thx:)