Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Pathfinding?

Discussion in '2D' started by PlayMyrthe888, May 24, 2020.

  1. PlayMyrthe888

    PlayMyrthe888

    Joined:
    May 11, 2019
    Posts:
    8
    Hi, I'm trying to remake an old game called ladybug, it looks a lot like Pacman. But I have a problem: I'm pretty new to programming and unity, and don't understand how to make the insects, they are a lot like the spooks in Pacman. I know I could use pathfinding but this doesn't work for me: This is one of my first games, and I don't know how to make the script myself. I know I could download A*, but this doesn't work for me because this isn't really precisely, and I need to use it in a small maze. Does someone have a solution?


    You can see the movement of the insects should be here.
     
  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    556
    @PlayMyrthe888 Why wouldn't the A* algorithm work in this case? This seems like a perfectly good solution for pathfinding in a maze such as this.
     
  3. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    these bugs don't look like they are tracking the player actually, it doesn't look that you need pathfinding, maybe you can just set them to move randomly, when they find a wall they turn to the open corner, or randomly change direction
     
  4. PlayMyrthe888

    PlayMyrthe888

    Joined:
    May 11, 2019
    Posts:
    8
    When I scan, it skips places where the enemy's should be able to walk
     
  5. PlayMyrthe888

    PlayMyrthe888

    Joined:
    May 11, 2019
    Posts:
    8
    Ty, but it looks like they are more likely to chose the path which leads to the player
     
  6. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    Hmm it doesn't look like it on the video, many times they even turn back when they will collide with the player and walk back and forth for no reason when theres a clear path
     
  7. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    556
    Can you post a screenshot of the walkability? I believe this is possible, but it has been a long time since i've used A* PP. I've always opted to write my own. At brief glace it appears the wall thickness being thinner than the path might be the issue.
     
  8. PlayMyrthe888

    PlayMyrthe888

    Joined:
    May 11, 2019
    Posts:
    8
    Ty, I solved the problem by rescaling the maze, which changed the thickness of the walls, and it looks like it works now thx!
     
  9. PlayMyrthe888

    PlayMyrthe888

    Joined:
    May 11, 2019
    Posts:
    8
    hi, thx for the reply, I solved the problem already but I want try your solution, to see what works best.. The problem is that I can't find how to make them move that way.