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. Dismiss Notice

Logic of a flying enemy

Discussion in 'General Discussion' started by Long2904, May 31, 2020.

  1. Long2904

    Long2904

    Joined:
    May 13, 2019
    Posts:
    81
    I want to make a 2d flying enemy. If you look at some popular game that has flying enemy like dead cells, rogue legacy,etc you can see there are a lot of ways to move the enemy (parabol, bezier curve, sin, cos function,...). So what is a general way of moving it or each game has a uniqe approach to this? And how to do that?
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,321
    There's no general way. Each movement type has its unique "mover" or "move algorithm" and that's it. That's the simplest approach.
    You could try to generalize paths as splines, but this is not necessarily worth it.
     
  3. sxa

    sxa

    Joined:
    Aug 8, 2014
    Posts:
    741
    Surely the movement path of an enemy is part of why you introduce that enemy in the first place? Enemies are active obstacles, so their movement and attack patterns inform, and feed back from, how you want to player to have to react to 'beat them'.
     
  4. Long2904

    Long2904

    Joined:
    May 13, 2019
    Posts:
    81
    For examples, how to make an enemy move like the "bat" in dead cells.
     
  5. TPEUnity

    TPEUnity

    Joined:
    Jan 17, 2018
    Posts:
    36
    Generate some sort of navigation graph in XY plane (i think i even saw some1 do this with unitys navmesh) then use A* or similar to solve path. I've used this style of approach for flying enemies or top down 2d pathfinding.