How to Add a Field of View for Your Enemies [Unity Tutorial]

Поділитися
Вставка
  • Опубліковано 29 лис 2024

КОМЕНТАРІ • 224

  • @its_just_matt
    @its_just_matt 3 роки тому +31

    This tutorial has the best thumbnail I've ever seen.

  • @Ophelos
    @Ophelos 3 роки тому +78

    Nothing like a little bit of trigonometry programming in the middle of a friday afternoon. Thanks for the video.

    • @comp3interactive
      @comp3interactive  3 роки тому +18

      Did I mention I hate maths... 😂

    • @revoxmediaHD
      @revoxmediaHD 2 роки тому +3

      @@comp3interactive luckily for you it wasn’t your maths or code but Sebastian Leagues

    • @hi-its-matt
      @hi-its-matt 2 роки тому +1

      @@revoxmediaHD wdym, did he copy code?

    • @revoxmediaHD
      @revoxmediaHD 2 роки тому

      @@hi-its-matt Copied it exactly

    • @adriatical9016
      @adriatical9016 2 роки тому

      woah, it's friday afternoon for me

  • @Demented_Chaos
    @Demented_Chaos Рік тому +4

    Man's out here saving my project with expert guidance, and now I know at least five new things about Unity and C#.

  • @thebeeshu771
    @thebeeshu771 Рік тому +20

    This is a 10/10 tutorial. It's not the simplest thing to make, but everything is so well explained and the editor script is the cherry on top of the cake.

  • @TwistdRabbit
    @TwistdRabbit 2 роки тому +5

    DUDE!!! I am making a VR fps with my 11y/o son as a summer project between college and Uni and you just saved me weeks of stress!!

  • @carpe.die.m
    @carpe.die.m 3 роки тому +5

    MULTIPLE TARGETS CHECK
    Hi,
    I don't know if this is 100% correct but it is just my explanation of what was suggested in the video for detecting multiple targets.
    "FieldOfView" script:
    1) Start( ) method: delete/comment out the "playerRef = GameObject.FindGameObjectWithTag("Player");" line
    -----> this reference is used just in the Editor script for drawing the Gizmo line but doesn't actually have to do anything with the detection of the target.
    2) in the FieldOfViewCheck( ) function , as the author said in the video 8:32, the rangeChecks array holds anything that has the targetMask on it and was detected in the radius around your player/character. Then we get one of these detected targets from this array and calculate in what direction this target is and finaly in the if statement with the Vector3.Angle, we calculate if it is in our FOV angle (if it is in the see distance, was automatically calculated by putting targets in our radius in the rangeChecks array).
    -----> So, here we just have to check this for each of the detected targets in the rangeCheck array.
    3) Create a for loop looping through all rangeCheck elements
    -----> after "if(rangeChecks.Length != 0)" and before "Transform target = rangeChecks[0].transform;". So, we can look at each element in rangeChecks and find out if we see it or not
    4) Change "Transform target = rangeChecks[0].transform;" to "Transform target = rangeChecks[i].transform;"
    -----> So, we are able to calculate stuff for every element in the rangeChecks one-by-one
    5) Inside the if statement where we set "canSeePlayer = true", assign the detected target gameObject from rangeChecks to our "playerRef" by adding "playerRef = rangeChecks[i].gameObject;"
    -----> So, we know we see a player/target/enemy and in the Editor script we can draw the gizmo line
    6) add "break;" under assigning the playerRef gameObject
    -----> this should stop the for loop calculating stuff for the remaining found targets in the rangeCheck[], because we found (at least) one player/enemy/target that we can see. But this doesn't have much impact since it breaks just this one for loop and the next time this method will be called in the coroutine this for loop will run again. Also, this has to be there if you are going to do the remaining steps!
    7) Inside the if statements where we set "canSeePlayer = false" write "playerRef = null" there (even to the very bottom else "if(rangeChecks.Length != 0){ }else{...here...}")
    -----> making sure PlayerRef doesn't hold any gameObject that we don't see anymore. So, the gizmo line is not drawn if there is no player/target/enemy in our sight.
    Please, read the coments to this (if there are any), maybe I made a mistake or didn't explain something in the correct way.
    Hope this helps and thank you for the great video, it has significantly improved my project and I learned a lot.

    • @ImFrantic
      @ImFrantic 2 роки тому +1

      Hey, your example worked fine. One thing I had to change was: after the *for loop* to check our objects we can no longer say -"Transform target = rangeChecks[i].transform"- since "i" can't leave the for loop. Instead we have to just do *"Transform target = playerRef"* since it was already changed in the forr lopp it's possible.

    • @ImFrantic
      @ImFrantic 2 роки тому

      In my Case *"playerRef"* is *"enemyUnits"* but anyways here's the finished code:
      void FieldOfViewCheck()
      {
      Collider[] rangeChecks = Physics.OverlapSphere(transform.position, visionRadius, targetMask);
      if (rangeChecks.Length != 0)
      {
      for (int i = 0; i

  • @ASeggsyPotat
    @ASeggsyPotat 2 роки тому +23

    It took me a minute to get everything working, but this was exactly what I was looking for! Now I just need to combine this with a few other tutorials (Making the enemy walk around, making the enemy walk towards the player etc) and I'll have the logic for my very first game done! Thanks a billion!

    • @Rize-TheArtOfPlay
      @Rize-TheArtOfPlay 2 роки тому +2

      Same. Combining the scripts is giong to be the hardest part I guess. Hope you had success!

  • @JimmyJohansson-pj1zx
    @JimmyJohansson-pj1zx 7 місяців тому

    Good programming tutorials are rare, so whenever I find videos like this I appreciate it a lot.

  • @Bobster536
    @Bobster536 2 роки тому

    I get so drawn into your voice, that i forget that im watching this tutorial to actually learn and just sit through till the end... Getting through one of yours to the point where id be satisfied enough with understanding the concepts took me ~6 rewatches. Great content my man love you

  • @DanielGarcia-ze9vy
    @DanielGarcia-ze9vy 3 роки тому +3

    Actually the best tutorial on enemy AI I have ever seen so far! I've been wondering so long for help on making raycast detection, thanks a lot!

    • @bakedpizza4037
      @bakedpizza4037 2 роки тому

      I am new to unity ... I am bit confused where to tell the enemy to do chase player or run any command on detection... Pls tell if you know

  • @AdamBarkerThe
    @AdamBarkerThe Рік тому

    Excited for your game next week!

  • @ImFrantic
    @ImFrantic 2 роки тому +11

    If anybody wants to know how to deal with multiple objects, here it is ( *in my case "playerRef" is "enemyUnits"* ):
    void FieldOfViewCheck()
    {
    Collider[] rangeChecks = Physics.OverlapSphere(transform.position, visionRadius, targetMask);
    if (rangeChecks.Length != 0)
    {
    for (int i = 0; i

    • @ImFrantic
      @ImFrantic 2 роки тому

      @@Shadowjones You're very welcome mate ^^ That's the reason I posted this here. Enjoy :D

    • @whitedragon44
      @whitedragon44 2 роки тому

      @@ImFrantic Really thank for this but I have one error. Cant use i++ in this line. for (int i = 0; i

    • @ImFrantic
      @ImFrantic 2 роки тому

      @@whitedragon44 is your rangeChecks an array? If it's not "Collider[] rangeChecks" it can't work because there is nothing to count.

    • @whitedragon44
      @whitedragon44 2 роки тому +1

      @@ImFrantic Collider[] rangeChecks = Physics.OverlapSphere(transform.position, radius, targetMask); You mean this?

    • @kioka2
      @kioka2 Рік тому

      Thanks! How do I detect the closest object among all those detected?

  • @troyna77
    @troyna77 Рік тому +5

    This tutorial is better than some unity store assets. why ? 2 reasons:
    1)you get to know the "nuts and bolts" of exactly what is going on.
    2) and you get the code explained.
    With a little bit of tweaking, I added my own shooting component and basic health system components. Still trying to figure out how to represent the "fov" during runtime. but thanks !!!

  • @jeffreydotson4842
    @jeffreydotson4842 2 роки тому

    My kind of tutorial! Clear and to the point without excessive stammering and/or over explaining.

  • @andreamansi2441
    @andreamansi2441 2 роки тому +1

    Damn, thanks, you saved me A LOT of time to build a decent AI visual detection algorithm for my university assignment. Clean and elegant implementation, easy to use (actually it cost me around 2 minutes ahah). Simple but powerful script! You should actually sell it, not joking. Thanks!

  • @Folghan
    @Folghan 2 роки тому

    Exactly what I was looking for. Great job man, I've tried everything and couldn't make it work, and your video saved me from seppuku.

  • @lukastomasek8038
    @lukastomasek8038 3 роки тому +10

    Great tutorial ! I would like to see more videos on custom editors for sure .

  • @azrhyga
    @azrhyga Рік тому

    Thanks very much for making this tutorial!! It is really helpful!!
    Thanks to this tutorial my enemies now have a field of view so they can detect the player more naturally :D

  • @nulltensor
    @nulltensor 3 роки тому +2

    Excellent tutorial. Very clear and well communicated.
    One minor nitpick though: "euler" is pronounced "oil er" rather the "you ler". It's a reference to the Swiss mathematician Leonhard Euler of Euler Identity fame.

    • @comp3interactive
      @comp3interactive  3 роки тому +1

      Ah that's interesting, I'll be honest, didn't know that was the pronunciation (obviously). You-ler is pretty well engrained into me now so that might be a hard habit to break 😂

    • @rudefatty1766
      @rudefatty1766 Рік тому

      🤓🤓🤓

  • @elric7371
    @elric7371 3 роки тому +12

    Good tutorial. Noticed an bug, when the player is slight above the enemies fov radius (still in the angle). It cannot detect player.

    • @SetharofEdgarDead-Rose
      @SetharofEdgarDead-Rose 2 роки тому +1

      needs to add Verticle element to this, or this only works on a flat ground game! Otherwise, this is an Ace Tutorial!

    • @somustache
      @somustache 2 роки тому

      It's probably because the radius is spherical and not circular for vertical movement. idk

    • @welcomelittlefellow
      @welcomelittlefellow 2 роки тому +2

      For future reference, you could try to set the y value on the transform.position and rangechecks[0].transform in the FieldOfViewCheck to make sure that the ray triggered higher above the ground (make sure to create new vector3 objects when doing that as you do not want to manipulate the gameobject transform, only for the check).

  • @paulberry3359
    @paulberry3359 3 роки тому +2

    Really enjoyed this tutorial, simple and powerful and Modular! Since doing your fps tutorial really motivated me to try other things and see what I can put together !

  • @krakuwdegustacja
    @krakuwdegustacja 3 роки тому

    best tutorial on enemy fov i've found

  • @agnarzb
    @agnarzb 2 роки тому +1

    Great tutorial. Very clean and to the point explanation.
    Would like to add that even it is not main concern of the video but I love the idea to add the editor part as well.
    Cheers.

  • @olcaval
    @olcaval 2 роки тому

    Thank you so much! You explained it perfectly. Now my enemy AI is finnaly working.

  • @mindergamestudios
    @mindergamestudios Рік тому

    I'm glad i found your channel.

  • @genofelice6034
    @genofelice6034 2 роки тому

    Thanks. This was the most useful tutorial I've watched in a long time.

  • @MrBanana12344
    @MrBanana12344 3 роки тому +3

    You could also just have the player layer and when you are doing the raycast you could type ~targetMask to see if there's anything that's not on the players layer in front of it. The ~ makes Unity check everything but that layer(s)

    • @comp3interactive
      @comp3interactive  3 роки тому +4

      100%, but then trouble arises when you have transparent objects like windows which you want the player to be visible through, or meshes with solid colliders but visible gaps, this way you can select multiple layers on the obstructionMask variable to cater for multiple obstruction layers/objects

    • @MrBanana12344
      @MrBanana12344 3 роки тому +2

      @@comp3interactive didn't even think of that, thanks for pointing it out

    • @comp3interactive
      @comp3interactive  3 роки тому +2

      Nah man it's always good to question methods, I could have made a point of that in the video tbh

  • @overcookedwalrus4482
    @overcookedwalrus4482 Рік тому

    Amazing video! Thankyou for holding our hands through this!

  • @QuantumChord
    @QuantumChord Рік тому

    Thank you for the tutorial, this should help me with designing enemy AI.

  • @unityvictor787
    @unityvictor787 3 роки тому +2

    Thanks for tutorial, Very simple to understand!!

  • @HarrenTonderen
    @HarrenTonderen 7 місяців тому

    Much thanks, been struggling to find something like this ❤

  • @muriilouwu
    @muriilouwu 6 місяців тому

    Thank you for the video, I used this logic to implement an aim system in my game :)

  • @camelChase20
    @camelChase20 3 роки тому

    This was perfect and immediately applicable for my AI controllers, thank you for posting!

  • @halivudestevez2
    @halivudestevez2 Рік тому

    Pretty advaced style tutorial. Just a bit of idea: at fov check, you can avoid the "else" hell spaghetti, if you set the canSee to false 8n the beginning and set again to true at positive check.

  • @Dosterczuk1321
    @Dosterczuk1321 Рік тому

    AMAZING! Thank you for sharing it! Works perfectly good!

  • @welcomelittlefellow
    @welcomelittlefellow 2 роки тому

    Just what I was looking for, thank you very much. Clear explanation!

  • @washynator
    @washynator 3 роки тому +1

    Awesome video and clear explanation! Thanks man!

  • @imeldaweijers3284
    @imeldaweijers3284 Рік тому

    Just what I needed, thank you so much for this little gem.

  • @kyrollosaziz7519
    @kyrollosaziz7519 3 роки тому

    absolutely need videos on custom editor tools with, it would be very useful to watch tutorials with such important topic in your great and simple explanation way.

  • @TheKr0ckeR
    @TheKr0ckeR 3 роки тому +3

    Thanks! It was really helpful! Both for Editors and raycasting! I would love to see Custom Editor scripts in the future! Is there anyway to visualize this angles in game too? So that its like a flashlight of enemies. :)

  • @chimz8057
    @chimz8057 Рік тому

    Awesome script my man! Thank you!

  • @its_Wooddy
    @its_Wooddy 2 роки тому

    Thank you so much for this tutorial! Really cool use of the gizmos for the FOV and very well communicated!

  • @AJMarraffa
    @AJMarraffa 2 роки тому

    Excellent tutorial, thank you! It was very easy to integrate into the code I had already written.

  • @ANGELB3AR
    @ANGELB3AR 2 роки тому

    Fantastic tutorial :) I'll definitely be checking out your other videos for more content like this

  • @corneliusbuckley8897
    @corneliusbuckley8897 3 роки тому

    Thanks for doing the maths for me! Such a simple yet super useful tutorial, I appreciate your work.

    • @comp3interactive
      @comp3interactive  3 роки тому +2

      And thank you for calling it "maths" and not "math" 😂

  • @netanelkomm5636
    @netanelkomm5636 Рік тому

    Works like a charm, thank you!

  • @kitsunedotexe3587
    @kitsunedotexe3587 3 роки тому

    currently using this tutorial for a really strange mechanic xD haha thanks!

  • @aussieraver7182
    @aussieraver7182 2 роки тому

    This is beautiful!
    Thanks for the tutorial!

  • @DTNenforcer
    @DTNenforcer 2 роки тому

    Very well explained. Thank you very much for an excellent tutorial.

  • @themari666
    @themari666 4 місяці тому

    Maybe I should just use collider with set trigger?

  • @РоманАфанасьев-ы8н
    @РоманАфанасьев-ы8н 9 місяців тому

    Hi. This tutorial is really fantastic thanks!

  • @unDeadGod69
    @unDeadGod69 7 місяців тому

    Really helpfull tutorial, thanks for uploading it

  • @dopplegangerdavid
    @dopplegangerdavid 2 роки тому

    Thanks for the info, Sean Connery.

  • @lerryotter1750
    @lerryotter1750 2 роки тому +1

    I have a problem converting this Script from 2d to 3d, i changed Vector 3 to 2 and forward to right burt it is still on the wrong axis...

  • @brianjirvin
    @brianjirvin Рік тому

    So followed this tutorial and works mostly, however the distance before player becomes unseen is roughly double the radius

  • @kioka2
    @kioka2 3 роки тому

    Very good, I learned a lot from your video, thanks for clarifying how to create a FOV! I have a doubt.. how to detect multiple players within the FOV and choose the closest player?

  • @Vasquez2701
    @Vasquez2701 3 роки тому

    Thank you very much! Saludos desde Guatemala.

  • @mrnickhox
    @mrnickhox 2 роки тому

    Saved my live thank you so much.

  • @nugraha000
    @nugraha000 Рік тому

    thank yu so much, u help me a lot bro. keep it up.👍👍

  • @patorino5295
    @patorino5295 Рік тому

    Thanks for the awesome tutorial. I followed your coding, and I noticed something. Should it be transform.forward in the angle check?

  • @miikajuhala6748
    @miikajuhala6748 2 роки тому

    Thank you so much for nice and clear video!

  • @coloneljcd6041
    @coloneljcd6041 2 роки тому

    Great vid! Liked and subbed

  • @Bobster536
    @Bobster536 2 роки тому

    If i didnt know of your FOVRoutine() solution, I would use a function inside of MonoBehaviour::Update(), and make the function start with a if(bool) which gets set to false for x frames after function does its job. Your solution seems just much more clear, if im getting it right.

  • @davidbarnaba7229
    @davidbarnaba7229 2 роки тому +1

    I Ecounterred an issue.
    I'm using the code on a 2D game, just a couple of differences (vector2 insted of 3 and transform.right instead of forward).
    When the player is really close to the enemy (with pov) but still in the cone of view, canSeePlayer become false.
    Can anyone help please?

  • @12edcorea54
    @12edcorea54 Рік тому

    very nice guide!

  • @raphaelrtf
    @raphaelrtf 3 роки тому

    OMG! You saved me! Thank you so much!

  • @umang9brainz
    @umang9brainz Місяць тому

    this video is very helpfull thank you

  • @saintpatronum921
    @saintpatronum921 Рік тому

    good job man!

  • @chimz8057
    @chimz8057 Рік тому +1

    HELP - Question for anyone who can help:
    I'm using this script, however my Player (and enemy for that matter) have their Pivot Points (or transform origins) at their feet.
    I managed to fix the Enemy's Raycast to be shot out of his eyes, but it's being aimed at the player's feet because of the above.
    What would you suggest I do to offset the transform in the script so it aims at the middle of the player. Changing the player's origin isn't possible so I really need to offset it in the script.
    Basically "target.position" needs to have its Y axis offset by +0.9, and I don't know how to apply it.

    • @chimz8057
      @chimz8057 Рік тому

      Well no one answered so here's the best way:
      Add a child object and place it in the middle (or where ever you want), and add an empty script to it.
      In the enemy vision script, set its target to that script, so it will look at the object which is placed where ever you wanted.
      The reason I say use a script and not tags, names, etc. is because scripts are easier to find. You can find it using "GetComponentInChildren" and do not require any Strings to work with which are a big no-no.

  • @javednoman3051
    @javednoman3051 2 роки тому

    nice work, how to use it in case enemy is above or some ledge, and it can see player down or up, i short a 3d cone type field of view mechanic

  • @Bobster536
    @Bobster536 2 роки тому

    I know its bit silly when just copying the code, but ive messed something up and was spending like 10 minutes looking at this one file of code and some settings, only after forfeiting and going back to your video i realised i had everything setup perfectly, just didnt start the coroutine

  • @pro100baobab
    @pro100baobab 8 місяців тому

    Good job! Thanks!

  • @flamyboy8043
    @flamyboy8043 3 роки тому +1

    i followed everything but my enemy still doesnt see my character ;-; (i enven checked the FAQ and still no dice)

  • @wortwortwort117
    @wortwortwort117 Рік тому

    How exactly can this be tweaked for multiple targets...
    8:23
    You mention adding a for loop but im unsure of how.
    I've added a for loop to determine the closest collider from the list of all colliders in range, but it will still only seek one regardless of if its visible.
    If i have 2 targets the enemy will lock onto the closest targe5 even if its behind a wall.
    The 2nd target can be entirely visible but will be ignored.

  • @slowman8385
    @slowman8385 3 роки тому

    Awesome video!!! Can u make a video about enemy hearing range?

    • @comp3interactive
      @comp3interactive  3 роки тому +4

      Dude, it's already on my to do list! 😂 Now I just need to find a celebrity with weird ears for the thumbnail 🤔

  • @simuloid
    @simuloid 3 роки тому +5

    Thanks for the tutorial, this is a nice solution, but I'm encountering some issues. When the player target moves outside of range, the raycast apparently still detects it. Also, strangely enough, the raycast appears to be triggered when the player is outside of the detection angle on the left side. Have you experienced this? Thanks.

    • @comp3interactive
      @comp3interactive  3 роки тому +1

      Double check you have all of the scenarios in your script where canSeePlayer is set to false. I did actually have this exact issue prior to recording and I forgot to set it to false in 1 place

    • @simuloid
      @simuloid 3 роки тому

      @@comp3interactive thanks for the quick reply! I actually didn’t change your script- using what you had on Git. I tried setting the canSeePlayer bool to false in Start, but didn’t appear to have any effect. Any other thoughts?

    • @comp3interactive
      @comp3interactive  3 роки тому

      If that's the case, the only thing I can think is have you set up an obstruction and target layer and assigned the layers to the relevant objects?

    • @simuloid
      @simuloid 3 роки тому +1

      @@comp3interactive All set- it was my error- sorry. Thanks again for the amazing tutorial and outstanding support!

    • @comp3interactive
      @comp3interactive  3 роки тому +2

      No worries man. Just glad it's working!

  • @viledeg2569
    @viledeg2569 3 роки тому

    Nice tutorial, but i wonder how to implement player detection that would work if any part of the player comes in view? Right now it's just detecting if the center of the player is in line of sight but in reality i think a more advanced approach may be needed when the enemy reacts even if only a part of the player is visible.

  • @uv-al
    @uv-al 3 роки тому +1

    Umm, im using HDRP, there is no editor folder, in the HDRP folder, (the one where the only editor folder is) has an editor folder but i cannot change anything in it, so i cant put a script in there, what do i do?

    • @comp3interactive
      @comp3interactive  3 роки тому +4

      You just need to create your own folder named "Editor", it doesn't matter where it is and you can have as many as you want, but anything in that folder/folders will be ignored when you build your game 👍

  • @endxrseeker5051
    @endxrseeker5051 3 роки тому +1

    My ai can still see me through walls, it shows the green line going through the walls. I have correctly labled and assigned the correct layer titles. Pls help

  • @hewston1
    @hewston1 3 роки тому +1

    excellent, thank you

  • @BF-sl5uj
    @BF-sl5uj Рік тому

    I keep getting "The name 'angleInDegrees' does not exist in the current context" for the FieldOfViewEditor script. Is anyone else running into this problem? I'm using Unity 2021.3

  • @jehdiaizon
    @jehdiaizon 3 роки тому

    amazing! thank you!

  • @xazza1080
    @xazza1080 Місяць тому

    I've copied the tutorial bar for bar, but my enemy is still seeing through obstructions, please help 🙏🏿🙏🏿🙏🏿

  • @johnnyjosefsen7644
    @johnnyjosefsen7644 3 роки тому +1

    It worked perfectly, until it just kinda broke. I probably did something, but not sure what. The script is identical (with the forward edit) but enemy sees player no matter how far away he is.

    • @johnnyjosefsen7644
      @johnnyjosefsen7644 3 роки тому +1

      God dammit, i put the enemy on the same layer, which broke everything. Now it works again.

    • @comp3interactive
      @comp3interactive  3 роки тому

      Good catch! 😂

  • @schizoscope8703
    @schizoscope8703 9 місяців тому

    It's detect position of collider but not collider itself. How can I change the script to fix it?

  • @matzo3679
    @matzo3679 4 місяці тому

    Thank you brother

  • @twelveminusone
    @twelveminusone 2 роки тому

    I really appreciate the video, this is exactly what I'm looking for! However, I may be dense, but I cannot figure out how to alter the direction of the FOV angle without rotating the game object. In my 2.5d game I've locked rotation and only let objects face left or right. Any guidance would be greatly appreciated!

    • @twelveminusone
      @twelveminusone 2 роки тому

      Answered my own questions! Just manually replace the eulerY value to whatever you want it to be. I added a "float viewAngle" that's clamped to 0,360 just like viewAngle and can manipulate it however I need it to be. Thanks again for the vid!

  • @Bobster536
    @Bobster536 2 роки тому

    yield return got me very confused. I would assume return means quit out of this function, but yield return means: pause execution of this code for x amount of frames.

  • @Mikelica69
    @Mikelica69 3 роки тому +1

    Thanks a lot ! 🙏🙏

  • @SP4ZE
    @SP4ZE Рік тому

    As a beginner - intermediate unity dev, this tutorial works, but the code is really confusing, when you started to code visualisation of for, it made 0 sense

  • @aokisea
    @aokisea 3 роки тому +1

    Mine doesn't trigger the "Can see player" bool even though there are no obstructions and the player is inside the view of the enemy with the script. Help please...

    • @aokisea
      @aokisea 3 роки тому

      Actually nevermid, I just forgot to put in the "StartCoroutine(FOVRoutine());" on the start. XD

    • @aokisea
      @aokisea 3 роки тому

      Thanks for the tutorial dude! Works very well!

    • @Mikelica69
      @Mikelica69 3 роки тому +1

      @@aokisea OMG THANKS I DID THE SAME ERROR XD

  • @tobiasnilssenopedal6660
    @tobiasnilssenopedal6660 Рік тому

    i got an error while making the editor script, " 'Handles' does not contain a definition for 'DrawWireArch' "

  • @lucasmattos5727
    @lucasmattos5727 2 роки тому

    Any way to have a solid color in the radius FOV?

  • @pixvee341
    @pixvee341 3 роки тому

    Thanks you're AWESOME :)

  • @TheJokerCard21
    @TheJokerCard21 Рік тому

    Does the physics have better performance over the mesh filter method?

  • @Bobster536
    @Bobster536 2 роки тому

    I was nearing the end of this tutorial and my player object is invisible on scene view, I didnt click the eye icon to make it so... big mess i could only assume some part of the scripts i wrote before messes up and modifies my player object transform to make it lose visibility or make it small to the point where i cannot see it, still great tutorial

  • @SystembolagetOfficial
    @SystembolagetOfficial 2 роки тому

    Ive encountered a problem with this script that doesnt seem to have an clear answer. Whenever my enemy looses sight of my player it just stops and starts to shake in different directions. Like it doesnt seem to find the exact spot my player was on.
    Another thing is that the enemies path-find perfectly to my player while playing the game in the Unity Editor, but as soon as i export a build of the game, the enemies just kinda randomly decide where to go once the player has been spotted. They dont run off tho, they just kinda waddle around the player.

  • @FutoOnYoutube69
    @FutoOnYoutube69 2 роки тому

    Hi! Would anyone have any idea how to implement this into a solution where it would go check the players last known location when out of sight? I've tried a few different ways but i can't quite wrap my head around it...

    • @pablosuarez9211
      @pablosuarez9211 2 роки тому

      every frame that the enemy sees the player, set some sort of variable to their position, then when they leave make the enemy go to that position, as it should be the place where the player last was before leaving

  • @zparklyztars
    @zparklyztars 3 роки тому

    I found out that sometimes the green line doesn't appear in the scene view until you press play. Could be worth checking if your green line isn't showing.

    • @espress0_1
      @espress0_1 2 роки тому

      Little late but thats because the functions update method doesn't run in editor mode only in game mode

  • @lukdev
    @lukdev Рік тому

    GOLDEN!