Add Killer Enemies to Your Game - 2D Top Down Shooter - Unity Tutorial

Поделиться
HTML-код
  • Опубликовано: 24 янв 2025

Комментарии • 40

  • @MuddyWolf
    @MuddyWolf  Год назад

    Access the FULL source code on my Patreon here: www.patreon.com/posts/2d-shooter-code-85313134

  • @derburgerr7416
    @derburgerr7416 11 месяцев назад +1

    great video helped me a lot

  • @hardyhu9999
    @hardyhu9999 Год назад +5

    can you add like enemy Health bar? so they don't die instintly + when you kill them blood particles will shower you? if you could that will be great .
    just a note your videos are amazing!

  • @sanake2636
    @sanake2636 4 месяца назад

    appreciate the videos man!

  • @jetsi604
    @jetsi604 2 года назад +2

    Amazing video! helped me so much, Thanks!

    • @MuddyWolf
      @MuddyWolf  2 года назад

      Awesome! I'm happy it helped, Jetsi!

  • @whataname6309
    @whataname6309 Год назад

    Thank you very much! On to the next one.

  • @adhoahsgamingdnd9617
    @adhoahsgamingdnd9617 2 года назад +4

    I enjoyed this video a lot, you explained movement pretty well, I'm searching for how to make enemies avoid obstacles while also chasing the player, I'm pretty stuck on that. Do you have any suggestions?

    • @MuddyWolf
      @MuddyWolf  2 года назад +1

      Ooo you can use A* pathfinding! If you RUclips it you'll find loads of tutorials but I recommend brackeys tutorial!

  • @monio_
    @monio_ Год назад +1

    When the enemy touches my player, the player starts spinning forever.

    • @RedditStories112-x9u
      @RedditStories112-x9u 7 месяцев назад

      Just doa check collision when the enemy touches the player you restart the scene:
      First at the top of the script do (using unityengine.scenemanagment)
      Then, write(Oncollisionenter(collision col):
      If(col.gameobject.tag == "enemy"
      Scenemanager.loadscene("You put her the index of the level")

  • @itsdonix
    @itsdonix Год назад

    Is there anyway to make the zombies take more shots to kill?
    very good tutorial btw keep it up. would love more to this tutorial serie.

  • @mitkorx3270
    @mitkorx3270 2 года назад +1

    Very good video you are great

    • @MuddyWolf
      @MuddyWolf  2 года назад

      Thank you so much 😀

  • @SmallToeSoap
    @SmallToeSoap Год назад

    this helps a lot thanks

  • @classysoda
    @classysoda 2 года назад

    can you help I have a problem on the 'Vector' could not be found

  • @RyanSadiku
    @RyanSadiku Год назад +1

    is anyone having an issue where the enemy isn't destroying the player when it collides with it? (Fixed - make sure that the player has been tagged as a player)

  • @jankystreams3337
    @jankystreams3337 Год назад +1

    I did every. single. bit of code you did, EXACTLY, replaying the video at least 10 times. My enemy still isn't moving. Please help me figure out what's going on.

    • @ByteKnite
      @ByteKnite Год назад

      Do you have a fix yet? I’m experiencing the same issue and I’m on a time restraint with this being a school project. Please share if you do have a fix

    • @jankystreams3337
      @jankystreams3337 Год назад

      @@ByteKnite I don’t sadly. I just kinda abandoned my project

    • @ByteKnite
      @ByteKnite Год назад

      @@jankystreams3337 I just deleted and retyped the code and it just started working. Idk what I changed but it started working

    • @jankystreams3337
      @jankystreams3337 Год назад

      @@ByteKnite That’s weird. Thanks.

  • @classysoda
    @classysoda 2 года назад

    Hello can you help me I have some problem about the enemy

  • @DR_Warr
    @DR_Warr 2 года назад +1

    Yay tysm!

  • @ketsueki血液
    @ketsueki血液 9 месяцев назад

    My player spawns on top of the enemy then cant move, someone pls help

  • @lobtig7035
    @lobtig7035 Год назад

    How is the word "other" italicized?

  • @edwarbladimir317
    @edwarbladimir317 2 года назад +1

    make him die from many bullets, that is to say: that the enemy has invisible life for the player but that he dies from 2 or 3 shots

    • @MuddyWolf
      @MuddyWolf  2 года назад +1

      Nice idea! We could add a life count and each bullet will take one life away until they die!

    • @edwarbladimir317
      @edwarbladimir317 2 года назад

      @@MuddyWolf 👍

    • @zer05tar
      @zer05tar Год назад

      @@MuddyWolf How about a boss where it has an HP and armor bar in which you have to get to zero before the boss starts taking health damage? Too much? >.

  • @swetiDevy
    @swetiDevy Год назад

    9:21

  • @umer11q1
    @umer11q1 Год назад

    plz give code for free

    • @MuddyWolf
      @MuddyWolf  Год назад

      You can copy and use the code from the video for free, however if you don't want to copy it out then you can get it via my Patreon by subscribing as a "Beta Wolf" - this is to support the channel and the tutorials I make for free.

  • @Rowland4825
    @Rowland4825 Год назад

    unfortunately there is something wrong with how i did it. it says "Assets\Enemy.cs(31,92): ; expected"
    Any help would be amazing. The my code is in the comment.
    I tried running it through spell check but I couldn't find anything. I also checked the tags and that not it ether.
    I tested it at 9:33
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Enemy : MonoBehavior {
    public Transform target;
    public float speed = 3f;
    public float rotateSpeed = 0.0025f;
    private Rigidbody2D rd;
    private void Start () {
    rb = GetComponent < Rigidbody>2D();
    }
    private void Update () {
    if (!target) {
    GetTarget();
    } else {
    RotateTowardsTarget();
    }
    }
    private void FixedUpdate () {
    // move foward
    }
    private void RotateTowardsTarget () {
    Vector2 targetDirection = target.position - transform.position;
    float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg - 90f; //the - 90f is because the triangle is naturally facing up. This will make it face the player.
    Quaternion q = Quaternion.Euler(new Vector3(0, 0, angle));
    transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed)
    }
    private void GetTarget () {
    target = GameObject.FindGameObjectWithTag("Player").transform;
    }
    }

    • @airconditioningac
      @airconditioningac Год назад

      as the error says, you're missing a ; on line 31 col 92,
      transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed);

    • @Bullet_D15
      @Bullet_D15 Год назад +1

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Enemigo : MonoBehaviour{
      public Transform target;
      public float speed = 3f;
      public float rotateSpeed = 0.0025f;
      private Rigidbody2D rb;
      private void Start(){
      rb = GetComponent();
      }
      private void Update()
      {
      if (!target)
      {
      GetTarget();
      }
      else
      {
      RotateTowardsTarget();
      }
      }
      private void FixedUpdate() {
      //Move Forwards
      }
      private void RotateTowardsTarget() {
      Vector2 targetDirection = target.position - transform.position;
      float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg - 90f;
      Quaternion q = Quaternion.Euler(new Vector3(0, 0, angle));
      transform.localRotation = Quaternion.Slerp(transform.localRotation, q, rotateSpeed);
      }
      private void GetTarget () {
      target = GameObject.FindGameObjectWithTag("Player").transform;
      }
      }
      Ahí tienes la versión sin errores xd habían cosas que fallaste que no falle pero yo falle en un } xddd, igual gracias por compartir me sirvió.