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.

Question How to make my character avoid everything I draw?

Discussion in 'Navigation' started by UNIDENTIFIEDPERSONALITY, Mar 8, 2023.

  1. UNIDENTIFIEDPERSONALITY

    UNIDENTIFIEDPERSONALITY

    Joined:
    Sep 29, 2018
    Posts:
    4
    So guys, the gameplay of my game is about an ant that needs protection from players. The players will draw a line to protect the ant from the obstacles. So basically, the ant is moving up (this is an endless runner game). Whenever the ant approach an obstacle, the player should draw a line and the ant will avoid the line and move left or right but still going up.

    I already made a drawing script based on this video tutorial (How to Draw in Unity with Mouse and Touch Swipes on Mobile - YouTube).

    My question is, how can I make my ant/character avoid the lines I draw and make it go left or right and still move up/forward?
     
  2. UNIDENTIFIEDPERSONALITY

    UNIDENTIFIEDPERSONALITY

    Joined:
    Sep 29, 2018
    Posts:
    4
    The ant should move up always. It will only move left or right if there is an obstacle in front of it and the player draw a line. This means that the ant should avoid the drawing of the player but will still go up after avoiding it.