2D Shooting | Unity Tutorial (Two Types of Projectiles!)

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

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

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

    I love these!
    Would want to see you cover the system part, like game saving, data structure, handling multiple scenes etc.

    • @sasquatchbgames
      @sasquatchbgames  2 года назад +3

      thanks! Already had two of those on my future list ;)

  • @Ramesss
    @Ramesss 10 месяцев назад

    AMAZING !!!! You saved me for my Second Semester project love you

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

    Have you thought about doing a tutorial on the weapon system? Switching between weapons, maybe adding UI icons, etc.

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

    Clear and comprehensible. Thank you!

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

    A much simpler solution for handling collisions is to just use the collision matrix in the physics settings. That negates the need for any code.

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

    2 time-saving tips: edit the script template so it doesn’t include all the boiler plate code you always remove anyway and there is a setting under preferences to create objects at origin so you don’t need to reset the transform every time you create a new GameObject.

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

      those are 2 things I've been procrastinating lol. Thanks for the tip, I'm going to have to do both of those

  • @mansimoe319
    @mansimoe319 9 месяцев назад

    Genuinely insane

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

    Love your devlogs

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

    A cool follow-up video would be how to use ScriptableObjects for bullet types.

  • @aazhisekar91
    @aazhisekar91 5 месяцев назад

    All of your videos are super helpful and very concise. Thank you

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

    Super helpful!

  • @grassbash
    @grassbash 3 месяца назад

    There is one thing that I need help with. When I rotate my gun, it has a weird pivot to it and it doesn't stay in its assigned spot. Please help!

  • @capilover1023
    @capilover1023 11 месяцев назад

    Please update the lesson for perspective camera! It seems to mess up your code

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

    Hi there! Great tutorial as always. I've implemented this after doing the Hollowknight style camera tutorial which took a bit of figuring out as it effected the rotation of the gun (if anyone wants help just ask). The multiple cameras caused problems.
    I am trying to modify this to suit my game. I have an ability system with upgrades and have tried to add a multishot upgrade, but its a bit buggy at the moment, it shoots three bullets at once in an arc but the extra two just shoot sideways :( I used Quaternion.Euler in the Instanciation of the bullet to be able to change its y axis rotation but that hasn't worked.
    I'm also struggling with trying to flip the character when rotating the gun past 90/-90 degrees like the gun. The player movement and jumping is turned off and the attack ability is turned on as well as the gun when holding down the attack button. The player can flip when aiming past 90/-90 degrees like the gun however, when exiting the attack (Releasing attack button), if the player is facing left it messes up the flip function of the player so that he is facing the wrong way when moving. I'm sure ill figure it out, but if anyone has a good solution for flipping the character I'd appreciate the help!

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

    I would argue that as you are setting the transform right to the velocity it doesn't need to be done inside a FixedUpdate.

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

      just gave it a shot in Update, and it produced weird janky movement. Definitely works best in FixedUpdate

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

      @@sasquatchbgames Then you did it wrong

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

    i have an issue with the layer mask

  • @ryanb2633
    @ryanb2633 9 дней назад

    If you want your gun to face the correct direction when character is flipped, change the HandleGunRotation function to this:
    private void HandleGunRotation()
    {
    float facingDirection = GetComponentInParent().localScale.x;
    //rotate the gun towards mouse position
    worldPosition = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());
    direction = (worldPosition - (Vector2)gun.transform.position).normalized;
    gun.transform.right = direction;
    //flip the gun as it rotates past 90 degrees
    angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
    Vector3 localScale = new Vector3(1f, 1f, 1f);
    if (angle > 90 || angle < -90)
    {
    localScale.y = -1f;
    }
    else
    {
    localScale.x = 1f;
    }
    gun.transform.localScale = new Vector3 (facingDirection, localScale.y, localScale.z);
    }

  • @Teles0704
    @Teles0704 8 месяцев назад

    my bullet is being destroyed when it spanws, what can i do?

  • @erikmarchini3274
    @erikmarchini3274 4 дня назад

    Honestly thank you very much for your tutorials, they're being really helpful, but i have to say that it's a nightmare to make it work, i must rely on chatgpt's broken logic which takes a ridiculous amount of time.
    I don't know if these tutorials are meant for beginners, but the logic implemented right here doesn't work when your character faces the opposite direction.
    Why would you talk about a solution to keep the bazooka from getting upside down when there are issues way more crucial to solve?

  • @suzyeon4222
    @suzyeon4222 9 месяцев назад

    when I rotate, the gun rotates in the wrong direction. Please help

    • @suzyeon4222
      @suzyeon4222 9 месяцев назад

      i mean the sprite rotates in the right direction but when im facing left side it's the opposite direction. sorry my English is bad

    • @lancerdev2391
      @lancerdev2391 7 месяцев назад

      @@suzyeon4222 Hi, I had the same problem and came up with a simple solution.
      Instead of flipping my player, I flip the sprite.
      Next, in my gun script, i modified this :
      float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
      Vector3 localScale = new Vector3(1f, 1f, 1f);
      Vector3 localPos = gun.transform.localPosition;
      if(angle > 90 || angle < -90)
      {
      localScale.y = -1f;
      localPos.x = -1f;
      } else
      {
      localScale.x = 1f;
      localPos.x = 1f;
      }
      gun.transform.localScale = localScale;
      gun.transform.localPosition = localPos;
      If flips the gun depending on the facing direction of the sprite of the player.
      Hope this helps !

    • @ryanb2633
      @ryanb2633 9 дней назад

      If you want your gun to face the correct direction when character is flipped, change the HandleGunRotation function to this:
      private void HandleGunRotation()
      {
      float facingDirection = GetComponentInParent().localScale.x;
      //rotate the gun towards mouse position
      worldPosition = Camera.main.ScreenToWorldPoint(Mouse.current.position.ReadValue());
      direction = (worldPosition - (Vector2)gun.transform.position).normalized;
      gun.transform.right = direction;
      //flip the gun as it rotates past 90 degrees
      angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
      Vector3 localScale = new Vector3(1f, 1f, 1f);
      if (angle > 90 || angle < -90)
      {
      localScale.y = -1f;
      }
      else
      {
      localScale.x = 1f;
      }
      gun.transform.localScale = new Vector3 (facingDirection, localScale.y, localScale.z);
      }

  • @tei_the_boy2367
    @tei_the_boy2367 2 месяца назад

    This tutorial just didn't really work there was multiple issues.

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

    At 5:45, you could have just used gun.transform.localEulerAngles.z instead of rotation. Correct me if I am wrong.
    In the end, you use interface and grab a reference to that instead of grabbing enemy script. The reason you say is because there are other objects that get destroyed by bullet. But, you wouldn't add enemy script on other objects. Right ?. So only enemy gets to have enemy script and you don't need an interface there.
    Really loved your video

  • @Coco-gg5vp
    @Coco-gg5vp 2 года назад +1

    First

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

    A more concise syntax is if (collision.gameObject.TryGetComponent(out var damageable)) …