Search Unity

Question How to do 2d Enemy follow with collisions and raycasts?

Discussion in 'Scripting' started by SpyderManToo, Feb 19, 2021.

  1. SpyderManToo

    SpyderManToo

    Joined:
    Dec 8, 2020
    Posts:
    387
    I want to make the enemies in my 2d top down shooter follow the player until he is within a certain range but all the tutorials on yt dont cover it with collisions and line of sight with raycasts.

    how do i make an enemy script where it will follow my player and still collide but stop following player if the player isnt in the enemy's line of sight?
     
  2. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    Have you seen this one?


    It's worth using 3D navmeshes in 'pseudo 2d' if you're not that far into it. ;)
     
  3. SpyderManToo

    SpyderManToo

    Joined:
    Dec 8, 2020
    Posts:
    387
    sorry im not rly looking for this stuff, im looking for an enemy ai script where it will follow me until a certain radius but still collide with obstacles