Unity 2D Platformer for Complete Beginners - #10 ENEMIES

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

КОМЕНТАРІ • 362

  • @PandemoniumGameDev
    @PandemoniumGameDev  3 роки тому +28

    Thanks for everyone for the patience, this one was a pain to record, I managed to mess up the video a couple times and had to redo it. Hope everything is clear and let me know if you need help, also check the GitHub project if you need the code: github.com/nickbota/Unity-Platformer-Episode-10
    For everyone who's getting UnassignedReferenceException when your fireballs hit something change this part of the code:
    collision.GetComponent().TakeDamage(damage); to this: collision.GetComponent()?.TakeDamage(damage);
    The ? will check if the object has a Health component before trying to damage it.
    ● Support the channel on Patreon or UA-cam: www.patreon.com/pandemonium_games
    ua-cam.com/channels/pkMj5b5kl2_YApDvgUCVQQ.htmljoin
    ● Subscribe to the Weekly Pandemonium Newsletter: www.pandemonium-games.com/#:~:text=About%20Me-,Weekly%20Pandemonium,-Subscribe%20to%20our

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

      lovely videos, you are an excellent teacher, thanks for helping us.

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

      Hello sir when I hurts my enemy he get die but still moving please sir tell me

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

      Epic video! idk why the channel is underrated I guess no one wants to become and Albert Einstein like you!(im not smart)
      Ahem.. Btw the EnemyFireball is not visible when he the enemy shoots but the invisible fireball still hits the player the sorting layer on the fireballs is set to Foregrounds so idk the problem Please Help dude!

    • @purejaguare
      @purejaguare 10 місяців тому

      I have a problem where the person dies but keeps moving when I move over him.

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

      Idk if I'm too late; but you can click the + icon in the MeleeEnemy/RangedEnemy script, and select the EnemyPatrol game Obejct in it. It would load up the script in it, and then it would also disable the EnemyPatrol script@@purejaguare

  • @mrsworder
    @mrsworder 3 роки тому +71

    Probably one of the best unity tutorials creator, you dont just make us copy the code( yes doing this we would create a game, but we don't learn nothing about how to make a game by ourself) , but you explain well how the code we just typed works! Sad to see the channel really underrated :(

    • @PandemoniumGameDev
      @PandemoniumGameDev  3 роки тому +9

      Really glad to help! Don't worry it's been growing steadily, also I need to be more consistent and put out more stuff

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

      Yo bro can you help me with the DamagePlayer() Event in Melee Attack in the script it is saying it is unused and in the unity editor its saying its not supported so how do you fix it? pls help
      Epic Tutorial btw Love it!@@PandemoniumGameDev

  • @tapthelvete
    @tapthelvete 2 роки тому +20

    I've been looking for reliable and easy to understand Unity tutorials and I hadn't found one... Until now. Your explanations are wonderfully constructed and I actually feel like I am learning. It's quite sad to see how little subscribers you have, but at least I can contribute by adding one more! Thank you for these videos and I hope you have an amazing 2022!

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

      Thanks a lot! It's been growing steadily, we'll get there

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

    Greatest Tutorial With All Details Ever Seen Here in my 1.5 year of learning started from WebDev to Get Understanding of Programing then Android App Development and finally half year ago started unity and that is were i want to stop Shout Out To this Man He is Incredible

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

    Wow... Underrated... Code actually works unlike other codes.

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

    Ive been waiting for so long, so happy the new one is out!

  • @アイス-w3m
    @アイス-w3m 3 роки тому +3

    Finally! Thanks so much! Your tutorials are really helpful and well organized.

  • @ushas3349
    @ushas3349 10 місяців тому

    Thank you so much for the wonderful unity 2D platformer series. I enjoy creating the games along with you. Usha

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

    This is the best channel in the world. I learned many things from you and applied them and became good at making games. Thank you.

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

      This is the best thing to hear! Thanks a lot and keep getting better 🔥

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

    Thank you so much I have been stuck on this for days. Really helped thanks.

  • @scorpiusjones5436
    @scorpiusjones5436 Рік тому +2

    Great series as always! Quick thing I found at the end of this tut is the EnemyPatrol object can be very specific about what variables are active in it. You have to plug these variables in when we first made it (I think they are "Enemy: Enemy" and "Enemy:Anim". If you add an enemy to the hiarchy that also has EnemyPatrol object, you must plug those variables back in or your enemy won't move/attack/idle. Maybe I just missed something, or maybe there's a workaround, but it's not THAT bad. Just good to keep in mind

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

    Following so far and loving it!

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

    Another good video. I got everything to work, and was able to solve any issues I had.
    I would like to share that the last issue I had was that my RangedEnemy Firepoint was not changing direction with the RangedEnemy's direction. I found out that the FireballHolder(the empty object that holds the Projectiles) had to have a similar setup as the Player in that it cannot be a child of the RangedEnemy.

  • @balab1622
    @balab1622 Рік тому +2

    i will not give up and finish this series !!!

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

    If you want a different enemy sprite that looks a bit different there is also ninja sprite sheet on the unity asset store by the same creator as the knight one.

  • @malwida1022
    @malwida1022 Рік тому +2

    I resolved an issue that bugged me for a long time: whenever the enemy changed direction, all enemy fireballs already in flight suddenly appeared on the other side of the screen, because the Enemy fireball holder changed direction along with the enemy. I couldn't figure out why this is not happening in the tutorial, and why behaviour was different for me. I finally fixed it by disabling the EnemyFireballHolder script (which follows the direction of the enemy) and instead implementing the same logic that is applied to the player fireballs (set direction in the PlayerAttack and Projectile scripts) in the RangedEnemy and EnemyProjectile scripts. Now everything works as expected, maybe this helps others with the same issue.

  • @markos_aki
    @markos_aki 6 місяців тому +2

    18:42 little optimization quirk
    Putting in "if(hit.collider != null)" inside the "PlayerInSight()" method to see if it needs to get the health component of the player means it's doing this check every single frame. Plus, it re-assigns "playerHealth" with the same value every frame the player is in range. But the method already returns the result of "hit.collider != null" at the end. The DamagePlayer() method already checks "if(PlayerInSight())" to execute "TakeDamage()", so it's basically doing the same check twice.
    You can just declare the "Raycasthit2D hit" variable as private outside of the method, which means DamagePlayer() will have access to it when it's called. You end up not needing the "playerHealth" variable. So it can just be:
    private void DamagePlayer()
    {
    if(PlayerInSight())
    hit.transform.GetComponent().TakeDamage(damage);
    }
    The only way PlayerInSight() will return true (and therefore run the next line) is if the "hit" variable currently contains the player object it has collided with in the check. Had no issues trying it this way. Saved a single glorious check per frame. Mom would be proud.

  • @Ray-wt2rr
    @Ray-wt2rr 3 роки тому

    Thanks for uploading. after waiting all this time

  • @prochysolaire9055
    @prochysolaire9055 2 роки тому +6

    I dont know why but i have the code completely same but my RaycastHit2D hit does not trigger when player is inside the red box

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

      did u solve it? and if yes, how?

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

      @@sogyshorts5662 Having the same issue as well!

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

    Thank you so much for this course, it is really helpful!

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

    If someone's fire ball is shooting without any cooldown, go to animation, and check the transition from ranged attack back to idle and make sure there isn't a trigger(ranged attack) there

    • @user-NguyenQuocDat
      @user-NguyenQuocDat 6 місяців тому

      my meleeAttack animation is called 2 times. How to fix it bro ?

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

    I still have a problem when melee enemy patroling the points he doesn't stop to hit me. He goes to the end of the edge and only than makes a hit///

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

    Another dumb question, my ranged enemy works perfectly. Except that when he is patrolling he is moving backwards haha. Like he moves right while facing left. He hits the right edge and turns, then he faces right and moves left. I'm using a different sprite but I'm sure it's something I'm overlooking. Thanks.

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

      I'm not a game engine guy i prefer coding everything , but i think the problem can be resolved by change flip depending on your sprite , if it is face right by default in left controller set it to true then set it back to false in right controller ,else do the opposite.
      Here's an example :
      ua-cam.com/video/XIEtt4GH_Mo/v-deo.html

  • @khnuxsora
    @khnuxsora 2 роки тому +4

    for some reason the animation isnt triggering ..i dont know why..the enemy is just standing on idle....i did the code like you did but the enemy wont attack the player

  • @PavanKumar-hs6qz
    @PavanKumar-hs6qz 2 роки тому +1

    MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.

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

      Unity is showing me the same error

  • @aychar
    @aychar 2 роки тому +4

    Would it not make more sense to make a base Enemy class and then have RangedEnemy and MeleeEnemy inherit from it to prevent copy and pasting your code?

    • @computernerd8157
      @computernerd8157 4 місяці тому +1

      I think you are correct. I know this is a year old, but its awesome when people who are learning think of optimization. Personally, I am glad he did not do it because it allows people learning room to grow.

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

    thANKS NOW I KNOW HOW TO MAKE A TIMER sorry for capslock im to lazy to change them

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

    i want to congratulate you for you r good tutorial ,but i have a little issue :
    enemy fireballs dont go into the right direction , and even by doing what you have done at minute 41:00 it didn't worked and i don't know how to fix , do you know something to help me?

  • @karun7275
    @karun7275 2 роки тому +4

    for some reason i get the red box but when the player walks into the range of the enemy the attack animation does not trigger and the player doesnt even get damaged.
    and i think the root of the problem is the raycast is not detecting the player is there as the animation when the player is in sight to attack is never called.

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

      i have same problem

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

      I have the same problem ;;

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

      no idea if this is still relevant, but I had the same problem and its probably not the best way to solve it but I simply put the distance value (5th one) > 0 and that triggered the animation for me
      RaycastHit2D hit =
      Physics2D.BoxCast(boxColl.bounds.center + transform.right * range * transform.localScale.x * colliderDistance,
      new Vector3(boxColl.bounds.size.x * range, boxColl.bounds.size.y, boxColl.bounds.size.z),
      0, Vector2.left, *0.2f* , playerLayer);

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

      Did you ever solve it? And if you did, what did you do?

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

      same Problem, did u solve it?
      @@sanjanar6218

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

    Hello, can I ask why my Enemy dissapears when i turn on the game, he goes somewhere under the ground so I cant see him ?

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

    Thank you so much for all these videos! Idk where I’d be without it!!
    Do you think you can show us how to make our character go between scenes, like going between levels?

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

    Where did you fix the error where the enemy continues to swing his sword over your body after you're dead?

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

    thank you just thank you man you are just amazing

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

    16:32 Hey, this problem is still there in my game and the melee enemy is not working.
    Plz help.

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

    Great tutorial but I have 1 mistake could you help me?
    When I kill an enemy he moves far away. What should i do my friend.

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

    When the enemy changes direction, the active projectile flips to the other side relative to the enemy. Is there a fix for this?

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

    'Guess i'll die' lmao you're the best :D

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

    so my problem is with the patrol and attack of the ranged enemy it moon walks left and right (faces the wrong direction its going) and the range doesn't flip with the enemy, i've downloaded the finished copy of this episode to make sure his is working which it is, so i copy and pasted all the code related the the ranged enemy into my scripts so the codes are the same and cross referenced everything in the inspector so all the positions, scales and script inputs are the same but it still broke ...help!

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

      i fixed my problem just by deleting the Ranged Enemy from the Enemy Patrols "enemy" and "enemy animator" functions then putting them back into the Enemy Patrol fixed my problem

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

    the EnemyFireball is not visible when he the enemy shoots but the invisible fireball still hits the player the Sorting layer on the fireballs is set to Foregrounds so idk the problem Please Help someone!

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

      Someone help as soon as possible

  • @Egor-kc2dx
    @Egor-kc2dx Рік тому +1

    Where does string create?: №57/№67 - "invulnerable", because it's string just already done on 47:57 min

    • @Egor-kc2dx
      @Egor-kc2dx Рік тому

      already see that in 51:17😁

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

    An easy fix for the firetrap is just to simply change the onTriggerEnter to onTriggerStay =)

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

    14:54 Is it neccesarry to take existing BoxCollider2D and using its properties make damage area. Is it possible to add second BoxCollider2D component just for that purpose or making damage area? Or would it be less optimized to do so?

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

    Hey, great videos by the way. I just have a question which i cannot find the answer to, at 33:02 I clicked on the MeleeEnemy and opened my Animator, but all the animator parameters just vanished. I can't find them. the parameters are there, just no buttons are showing up. My die, is gone, moving, melee, ranged and hurt are vanished. any suggestions?

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

      Yeah, it's a common Unity bug. Just restart it and it should go back to normal

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

    Can’t you just put a script on the enemy that stores the starting position and the allow distance from start, and then do calculations in update to get the patrol behavior? Like is there a reason we need 4 objects just for 1 enemy? Genuine question.

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

    My ranged enemy keeps shooting fireballs even when the player is out of sight while he is walking in the opposite direcetion!
    Any reasons for that? thanks for the videos, great tutorials as usual.

  • @rorywalker4770
    @rorywalker4770 Рік тому +2

    Thanks for your tutorial! Is there a reason why you keep using Vector3 for a 2D game?

    • @PandemoniumGameDev
      @PandemoniumGameDev  16 днів тому

      Glad to help! Yes, Unity mostly uses Vector3 since it's a 3D engine, so it needs 3 coordinates for most functions even or 2D games. There are some exceptions where you can just use a Vector2 but it in my opinion it's just easier to use Vector3 in most places

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

    One question: Enemy can move while he is attacking ( if i move away from it). Is it some quick fix of that?

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

    Awesome videos! Are helping me a lot to learn how to proper use Unity

  • @MORIARTI27
    @MORIARTI27 8 місяців тому +1

    Hello, can you help? Very necessary!! 1. The enemy continues to hit when he is patrolling and when he killed me. 2. When my character is dying, he continues to move, and when I jump, his image appears, what should I do? Perhaps someone knows...

    • @stxrmx3548
      @stxrmx3548 5 місяців тому

      I have the same issue, did you fix it by any chance?

    • @stxrmx3548
      @stxrmx3548 5 місяців тому +1

      Nevermind, I fixed it. You just need to rewatch this moment - 32:15. The issue was in health script, so just write code more carefully

    • @MORIARTI27
      @MORIARTI27 5 місяців тому

      Okay

    • @Артем-ъ1ъ4ф
      @Артем-ъ1ъ4ф 5 місяців тому

      ​@@stxrmx3548 My enemy hasn't changed, he still beats me when I'm already dead

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

    Hi, I´ve got a question. Where do you got the EnemyProjectile Script???

  • @oanhtuan4245
    @oanhtuan4245 3 місяці тому

    Hi, I followed the instruction at around 5:08 , i did exactly what the video shows step by step but first, it shows : "Transition Idle - Attack in state Idle doesn't have an Exit or any condition , transition will be ignored" after i added the attack condition my enemy always doing the attack anim and not idle state, Anyone know how to fix?

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

    This is absolute awesome. I have just one question. When i create event on end of animation die when i kill enemy he stop using those two scripts but he will not disapeare and because of the script enemy damage can still hurt me.

  • @onlinewarriorspodcast
    @onlinewarriorspodcast 11 місяців тому

    Not sure if anyone had this issue but when I would press play the MeleeEnemy would disappear. The only way to get it to work was to change the value of "Near" to -10 in the Clipping Planes under "Main Camera" If anyone knows why this was happening to me/ why this solution fixed the issue, the feedback would be greatly appreciated.

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

    i have a problem, my ranged enemy only shoots fireballs for 1 frame and then they disappear

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

      Same :/

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

      Still not sure what was causing the issue but deleting RigidBody2D component and setting resetTime to 15 worked for me. Hope this helps :D

  • @WildChild343
    @WildChild343 Рік тому +2

    If anyone else is having issues detecting player with RaycastHit2D change this part "boxCollider.bounds.size.x * range" to this "boxCollider.bounds.size.x" in the second parameter of the BoxCast function. For example:
    private bool PlayerInSight()
    {
    RaycastHit2D hit = Physics2D.BoxCast(boxCollider.bounds.center + transform.right * offset * transform.localScale.x * colliderDistance,
    new Vector2(boxCollider.bounds.size.x, boxCollider.bounds.size.y),
    0, Vector2.left, 0, playerLayer);
    Debug.Log(hit.collider);
    return hit.collider != null;
    }

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

    Thank you so much for releasing a new tutorial. Been following this series and making my very first platformer! Out of curiosity, why not use the new PlayerInput system for the controls, or the Cinemachine for camera movement?

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

      Hey there, it would've been a bit easier probably but I wanted to start with the basics not use any packages.

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

    I have a problem with enemyPatrol. I was follow your video many times but I can't found what's the wrong is. while on patrol to the left, he walks backwards and the scale doesn't turn to minus. Can you help me please?

  • @ushas3349
    @ushas3349 10 місяців тому

    Hello, in the firetrap episode you said you corrected so that player takes damage when he steps on to the firetrap and sit there idle. But I folled all your corrections. But still player does not receive any damage when he sits on the firetrap continuously without moving!
    Pl give me some hint to solve this issue.

  • @vector866
    @vector866 4 дні тому

    I have a problem with enemy patrol, when i run it enemy turns right but he doesn't move right like for you in the video. Can anyone help?
    Edit: My death animation was the issue, it works now

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

    The boxcast/playerinsight function returns true no matter what, even if my player is clearly in the box. I saw that you had IsTrigger activated, but doing so makes my enemy clip through the floor. Really confused, need help!!!

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

    im on the patrol part and for some reason i dont see the enemy when i start the game, unless i disable the animator and than its working good just without the animations of course... any idea what could happen?

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

      switch off trigger in boxcollider2d of character or...

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

    friend, I have a problem, I did everything right and if I came out with an enemy, but when I create another and put the scripts into it, it doesn't hurt, it can perform all the animations but it doesn't hurt the player and it doesn't give any errors, what could it be??

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

    First of, I want to say that you have a great tutorial! I have been following ur first until this video for my personal project. Unfortunately, I'm having an issue in Ranged Enemy AI. Specifically in 40:08, I could not get to play in Unity, as I encountered an error message "UnassignedReferenceException: The variable anim of enemyPatrol has not been assigned." I also see that in 39:48-39:50 in your video, which mentions how you do not have the enemyPatrol assigned. I tried following your tutorials and even tried restarting your video to see the issue, but haven't figure out how to solve it yet. What seems to be the problem and how can I solve it?

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

      Hi, did you find the problem?

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

      @@dezaraogre nvm, its alrdy solved. Thanks for reqching out tho

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

      @@ryanmondong9835 same on me , can u figure out how to solve that ?

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

      wht a legend, still liking my comment even tho the it is 2 months ago

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

      Solution. Disable EnemyPatrol., until Pandemonium turns his back on.
      For those looking for the answer.

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

    enemy teleports to location of where i did the animation
    edit: i had to apply root motion then it works.
    lmao every time i get a problem that the internet cant fix i post my problem in the comments then after a few minutes i find a fix.
    but i have another problem where the enemy is staying idle when i go inside the box

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

      You probablly did some animations wrong. And you have to set the right tags on the player as "player" and enemy as "enemy".

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

    please help, i followed exactly your coding and steps but the enemy patrol not moving to the right and left edge. idk wheres the problem

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

    Hey keep getting this in your damage enemy section,
    NullReferenceException: Object reference not set to an instance of an object

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

      Nevermind, apparently I may have installed the right extension for it

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

    Hi. I just have a question which i cannot find the answer to, at 47:33 to 47:43 what to do. did not change RangedEnemyHolder to MeleeEnemy. I did not understand this part 47:33 to 47:43. What did you do?. Please help me

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

    Im having some troubles making it turn, for some reason it does the patrol but its not actually turning when it gets to the other side. I check the code and everything seems ok, melee one works, ranged one doesnt.

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

    I've run into a bug that I can't figure out. So the line of sight was working properly with my melee enemy. However in working on the ranged enemy his line of sight is no longer flipping with him. So it starts off fine in the correct direction he's facing. Though the enemy walks backwards rather than forwards. Then when he gets to the patrol edge he turns around but the field of vision gizmo stays the same direction. so if the player is behind him, it triggers the enemy to fire a fireball. However the fireball still fires forward away from the enemy but is triggered from behind the enemy as his field of vision doesn't change. He also continues to walk backwards if you're out of his "line of sight". I've checked all my scripts to yours but they look fine to me. No errors are compiling in Unity. So I have absolutely no ideas on how to fix this issue. I also tried changing his direction of both the ranged enemy and the ranged enemy holder but this only seems to flip the sprite so he may then walk in the correct direction but his field of view still doesn't change. Same issue if I change just one of the objects direction he starts walking the right direction but his field of view stays behind him.

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

      Well update after playing around with the x position on the ranged enemy and Ranged enemy holder I fixed the walking backwards issue. The enemy now flips but I still cant get enemy field of vision box collider/gizmo to flip. So the enemy walks forwards and heading one direction his line of sight is in front of him but the other direction the box is behind him. I know we wrote code to make the box flip too, but again I've checked all my code a few times now and I'm not seeing any errors to fix this issue.

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

    I followed you exactly but the enemy just ignores me and continues to patrol. He does not stop and attack. What could I be doing wrong?

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

    HELP PLEASE!!!
    why changes in scene don't apply in game mode??

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

    Help me, I can't see the Collider Parameter in the scene, it seems to be hidden, I can't see to adjust

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

    41:28 the EnemyFireballHolder script causes the enemy fireballs to shoot at the enemy when it is facing the left. When it faces right, the fireballs shoot to the right. [EDIT] I solved this. Answer is in the reply.

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

      I figured out my problem. I had incorrectly set the game object hierarchy and Firepoint was not a child of RangedEnemy. If you are following along, make sure you're checking your game object Child / Parent structures. I was so tired I didn't realize I had overlooked where it was sitting. Interesting how something so small can have such a large effect.

    • @vector866
      @vector866 2 дні тому

      @@micahburnside2281 Weird im at the same exact problem and firepoint is child of the Rangedenemy and he still shoots himself when facing left

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

    Hey, I didn't wanted the range enemy so I didn't change the way how the script Health works. Will this cause problems for me in the next tutorials? (In my case just the audio tutorial and the chekpoints & respawn tutorials).

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

    Not sure if someone still can answer my question but I got an issue when my player gets hit
    The player is out of the range of the enemy but still get damage. How to fix that issue? I am using a linecast to check if the player is in range

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

    @PandemoniumGameDev In the unity console it is displaying that the "animator for the melee enemy has been destroyed but you are still trying to access it" Can you suggest a solution to this
    btw love your tutorials

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

    45.02 patrolling behavior is not working. If anyone knows how to fix it please tell me.

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

    Pandemonium, I have a problem with my game. I've typed the code like yours, but the problem in second 23:16 still occurs. Do you have any idea what should I repair?

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

      Having the same problem... Did you get the solution?

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

      @@freestylerak6655 no i did not

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

      @@marutorii no problem bro, I fixed it

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

      @@freestylerak6655 lucky to you

  • @stepanchladek5022
    @stepanchladek5022 11 місяців тому

    Hi, I had a problem with scaling my sprites. Knight on the video is on transform scale: 1, but my enemies are on scale 0.2 when I want the same height as my dragonknight. Yeah I could resize all my enemies to correct resolution size, but I didnt want to do that. So, the problem: When I resize my enemies - then Gizmos and RaycastHit wasnt same height as my box collider - it was actualy two times bigger.
    Fixing this bug was quite easy (But for my dumb brain it was like 40 minutes strugling): You need to add to your new Vector3 transform.localScaleY.
    So the code for Gizmos is: Gizmos.DrawWireCube(boxCollider.bounds.center + transform.right * range * transform.localScale.x * colliderDistance,
    new Vector3(boxCollider.bounds.size.x * range, boxCollider.size.y* transform.localScale.y, boxCollider.bounds.size.z));
    And for RayCastHid2D: RaycastHit2D hit = Physics2D.BoxCast(boxCollider.bounds.center + transform.right * range * transform.localScale.x * colliderDistance,
    new Vector3(boxCollider.bounds.size.x * range, boxCollider.size.y * transform.localScale.y, boxCollider.bounds.size.z), 0, Vector2.left, 0, playerLayer);
    Sorry if this is stupid or apparent, but I havent seen anyone mention this here.
    Also sry for my English, I am just dumb :D

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

    I got everything in this video to work with the exception of the collision with enemies causing damage. My enemies are being treated like solid objects, so my player is blocked by their hitboxes and is able to stand on top of them. Any suggestions as to what can be causing this?

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

      Pretty sure it's a quick fix. Change the colliders on the enemies to be On Trigger

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

      @@PandemoniumGameDev Thankkks

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

    Great Tutorial :D Love it :)

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

    why does my fireball only has short range of distance? it dissapear before even collide with anything

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

    hello i have problem about damage enemy with fireball, fireball not damage enemy but enemy stop moving when i shoot 3 fireball ( i copy/paste you code but not working )

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

    I'm having a problem with my arrowtrap ever since I changed the enemy projectile script every time it hits the player or the wall it stays frozen there and keeps shooting. I think because it's not disabling when it hits anything. Any opinions?

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

    Hi, thanks for the tutorials, very helpful. I'm hoping you can help me with something? My melee enemy is patrolling the space I assigned but he is walking backwards? Any ideas?

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

    Solved the problem when enemy patrol , it's not damaging, put
    if (enemyPatrol != null)
    {
    enemyPatrol.enabled = !PlayerInSight();
    }
    instead of
    (enemyPatrol != null)
    enemyPatrol.enabled = !PlayerInSight();
    Hope it will help someone, because it helped me.

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

      Thanks
      but my enemy doesn't activate attack animation when I go into his red zone, why?

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

    I am trying to figure out how to implement the enemy damage in my code which I have made a few tweaks to to not include player projectiles. I want to handle the damage the same way but just on the mouse click. How would I incorporate that?

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

    Hey man, sorry I'm a little late to the party but I'm having some issues with the enemy patrolling script. I have set up everything they way you have it in the video, assigned all the parameters, however, when I run the game in unity the enemy is teleported to the right edge point, has turned left and is performing the walking animation but not moving. Any ideas you can run by me?

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

    Hi love your videos but had a problem in wall jumping tutorial my jumping became infinite again

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

    I'm making a basic box game and i just wanted to know wether the enemy animation is neccessary for taking damage (wich it probably isn't(i dont really want to make animations because boxes dont usually do anything)) because every time i walk up to the enemy nothing happens. Even when i created an object that should damage the player nothing happened. Also the enemy is invisible even tho it has a sprite renderer.

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

      It seems like i forgot to save the file and it didn't load in unity lol. Now i got a compile error so ill go fix whatever its saying

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

      Dang im too stupid to fix it

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

    Hey i have a problem, when i set my layer to player he free falls through the ground, is there any fix to this?

  • @ケンチ-e6d
    @ケンチ-e6d Рік тому

    Sorry, I followed your course. When I did the 41:48 part, I wanted the enemy in my range to be able to shoot arrows, but after he detected the player, although he shot the arrow, it disappeared instantly. Why is this? By the way, I didn't animate my arrows, could it be related to the animation?

    • @ケンチ-e6d
      @ケンチ-e6d Рік тому +1

      I found the problem, my arrow point is too close to the enemy, causing it to disappear instantly when it is shot.

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

    plz, help me, my RangedEnemy can't movement with patrol, when I input RangedEnemyHolder to Patrol he can move around but collider box is not change position.......sorry, my English so BAD =(((((((

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

    i want to ask do you know how can you make character transformation for example like goku from dragon ball love your tutorial btw

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

      Yeah, you have a couple options. 1. Change the entire character sprite or 2. Divide the character into a couple images: hair, chest, arms etc and then change the sprite or color on each individual element like Goku's hair turning yellow.

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

      @@PandemoniumGameDev Does change the sprite effects the animation?

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

    'FireBall (8)' AnimationEvent 'Deactivate' on animation 'Fireball_explode' has no receiver! Are you missing a component? does anyone else get this please i need help

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

    Why i dont see any animation set up for the fireball on explode animation?

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

    Nice tutorial! I finally have my ranged enemy patroling perfectly in the scene but when I try to create a prefab of it to use it in another scene it just don't work for some uknown reason. It keeps patroling but he doesn't attack the player and I have all tags displayed correctly. I thought it was a bug but it does the same in older versions of unity. I just don't find how to solve it!

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

      hey did u fix the bug ? bcz I have the same pb T-T

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

      It could possibly be because the Ranged Enemy does't have any movement logic attached to it alone, that's in the Enemy Patrol script. It seems like anytime I remove/add a enemy to the scene, I need to plug the info into the Enemy Patrol prefab in the hiarchy to make the enemy patrol

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

    Hello. I have a question.
    I have a GroundSpawner and EnemiesSpawner and my enemy with isTrigger Box Collider 2D just keps falling down through the platform. How can I solve this problem? Can do it only via coding or there's another solution?

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

    Thank you for uploading. May i ask when u will upload the game over??

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

      This weekend I'm finishing the audio & music episode, then the game over screen is coming next week probably.

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

    hey, was just wondering that is there any way to make the player damage the enemy through melee attacks.i followed through all the scripts but i did not wanted to add a projectile attack system but now im stuck as i dont know how to damage the enemies through melee attack

    • @itsyourgamer3786
      @itsyourgamer3786 4 місяці тому +1

      hey, nevermind. after hours of hit and trials and some useful tutorials i was finally able to get my way through it. And btw youre the goat.

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

      @@itsyourgamer3786 Good luck for you !