Unity: 2D Shooting

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

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

  • @RootGames
    @RootGames  3 года назад +16

    HINT: If your bullets move too fast, sometimes collision can't be detected. Select your bullet prefab and in Rigidbody settings, set Collision Detection to "Continuous"

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

    To give so much knowledge to create a playable game in a shade over 4 minutes is just unbelievable. Sir, you just won yourself a follower 🤩

  • @CarlosVS-o2r
    @CarlosVS-o2r Год назад +2

    This tutorial was amazing. Thank you a lot

  • @Poisoid
    @Poisoid 12 дней назад

    is it possible to implement score that updates with firebase?

  • @aryamukasyaf146
    @aryamukasyaf146 10 месяцев назад +1

    Thank u for the great insight

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

    im having some trouble with anything from the pack even coming up, i might just be stupid but it would be great if you could help me with that!. anyway i love all of your videos (:

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

    1:07 whene i come back to the unity it say "Method must have a return type"" I did evry thing that you did and try every thing. plz help I am in a geme jam and i need to fix it fast

  • @kartikbhagwat7872
    @kartikbhagwat7872 Год назад +2

    How did you created enemy prefab and spawner? I'm Confused :(

  • @JebonneL-zx5wc
    @JebonneL-zx5wc 6 дней назад

    What about using the legacy input system?

    • @RootGames
      @RootGames  5 дней назад +1

      Don’t use it, the new input system is better in every way. You can check my input course about the new input system and how to correctly use it (with rebinding)

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

    What's in the 1st to 10th lines of enemy.cs ?

  • @Ryu-ky5vt
    @Ryu-ky5vt Год назад +1

    Thank you very much bro subbed immediately

  • @RatSentinel
    @RatSentinel Год назад +2

    great tutorial, definitely deserves a sub

  • @rec.official
    @rec.official 11 месяцев назад +1

    Really cool one 👍

  • @Nyle.A
    @Nyle.A Месяц назад

    can I make it so that I can switch the shooting point without pressing the down button

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

    What would be a good way to add a delay between shots?

    • @RootGames
      @RootGames  2 года назад +8

      Create a timer. For example:
      float timer = 0;
      float shootDelay = 0.2f;
      void Update()
      {
      if (Keyboard.current.spaceKey.wasPressedThisFrame && Time.time>=timer)
      {
      Instantiate(bulletPrefab, shootingPoint.position, transform.rotation);
      timer = Time.time + shootDelay;
      }
      }
      You can create other types of timers, this is just one example.

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

      @@RootGames Got it. Works great! Thank you.

  • @joacohoffman1729
    @joacohoffman1729 5 месяцев назад +1

    Thanks!

  • @Amigo-oh2vv
    @Amigo-oh2vv Год назад

    Thanks for help
    But how to make it the longer you press the shooting button the more dammage you deal

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

    i need a full screbt in document file plz :)

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

    How can i make it so instead of flipping the character around it flips the Shooting Point and makes it fires in the other direction, when i flip my controls get mixed up

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

    Is this the same game you taught in the course?

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

      No, if you click on the Udemy link, you can watch a preview of the course.

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

    hello is there a way you can just teach me the enemy and killing the enemy tutorial and if you already have one can you please tell me which one? because when I try get the enemy and damage it just gives me errors

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

      Seems like you also need to learn the basics of C#. Try my course on Udemy/Skillshare. You will learn C# from scratch and there is also a section about enemies.

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

    At 0:45, how would I make it instead shoot when clicking the mouse?

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

      Depending on what input system you are using, old or new. If you want to learn more about the new input system and C# in general, try my course on Udemy/Skillshare.

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

    When I rotate, the shooting point doesn't move with my player, how do I fix this? (I also connected it to the player script

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

      It needs to be a child object of the player.

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

    How would you make this continuously fire when holding down the shoot keybind.

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

      You need a timer and use Keyboard.current.spaceKey.isPressed

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

    thanks

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

    Hi, I copied your code for the bullet but it comes up with lots of errors :(. I was wondering if it's maybe, because I'm using the 2022.3.11 version of unity?

    • @RootGames
      @RootGames  10 месяцев назад +1

      No, it’s not.

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

      This is the code that I have for bullet and it keeps coming back with 10 errors :(
      Some of them say things like "The modifier 'private' is not valid for this item" or "Type or namespace definition, or end-of-file expected". I'm pretty sure I followed the tutorial and copied everything correctly.
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Bullet : MonoBehaviour
      {
      public float speed;
      private Rigidbody2D rb;
      void Start()
      {
      rb = GetComponent();
      rb.velocity = transform.right * speed;
      }
      }
      private void OnTrigger2D(Collider2D collision)
      {
      Enemy enemy != null)
      {
      enemy.TakeDamage(20);
      }
      Destroy(gameObject);
      }
      }@@RootGames

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

    goated tutorial

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

    What about the Spawner script?

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

    Can you make a clone of the bullet removed when it passes through the camera?

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

      To destroy bullets when they go off the screen use OnBecameInvisible and Destroy functions.

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

    is there a way i can shoot in the direction with scaling the player to -1 and 1

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

      Yes, you need to have a variable that will store the direction of the player, for example: 1 when he is facing right, -1 when he is facing left, then when you instantiate your bullet prefabs, pass that variable to them and multiply the speed with it, the bullets should fly to the right and left depending on the direction variable.

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

      @@RootGames how to can store the veriable for direction of the player if the bullet is in a different script?

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

      @@munroy529 When you instantiate the bullet, use getcomponent for the script in which you store directions. Then pass it to the bullet in the "Start"

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

      can u explain the practical system that u made in the video ?@@RootGames

  • @GameWithMe469
    @GameWithMe469 Год назад +2

    my projectile is not moving and i don't know why

    • @droniedji
      @droniedji Год назад +2

      I had the same problem ???

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

      I can spawn the Bullet in but not get it to move

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

      Spawn the bullet and then pause the game. Inspect your spawned bullet. It has to have the Bullet script and Rigidbody2D component. Also check that the speed variable is not 0.

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

    does not work says redParticles does not work in Enemyscript

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

    My bullets jus fly in to one direction😂

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

    How to enemy get a damage?

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

    i cretead a bullet but it doesnt flip side, its always shooting to the right side

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

      Maybe you are flipping the player using scale and not rotation.

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

    Hi, Shooting Point (and bullets) doesn't flip with my player. How do I correct that?

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

      Shooting point needs to be a child object of the player. Then use rotation as mentioned in the video and it must work.

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

      Problem is I'm using a different player sprite and script to yours and the rotation code will mess up my sprite

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

      Also the bullets only fire right.

  • @easyminecrafttutorial809
    @easyminecrafttutorial809 3 года назад

    root games would you make about double jump or enemy that shoots bullet pls

    • @RootGames
      @RootGames  3 года назад +1

      The double jump is covered in my Udemy course.
      I can give you an idea of how to make enemies shoot but there are so many types of enemies. The principle is the same, instantiate the bullet prefab from the enemy shooting point. You can do it with a timer or when the player enters a certain area, then start shooting.
      Thanks for subscribing :)

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

    can u tell more detail about spawner

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

      use instantiate along with a empty game object to declare where to spawn your prefab

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

    It sadly breaks my entire character i start rotating infinitly

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

      can i see your movement script?

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

    Where is the redPartical File. What is written there.

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

      Red Particle is a particle system prefab.

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

    My bullets fell straight to the ground

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

      Make sure you set gravity to 0.

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

    Using the new Input system fucks with my other scripts

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

      You can do the same thing with the old system, but consider shifting to the new. The old one is ditched by Unity, the future is the new system.

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

    I love you i think

  • @crshorts-6286
    @crshorts-6286 Год назад

    Im so bad at developing that even this does not work for me

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

    its hard to follow you can u slow down a bit

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

    3:33

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

    better write [SerializeField] private

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

    Upload The Code.

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

      Sorry, I don't have it anymore, but you can see everything in the tutorial. The only thing you need to create is your Particle System prefab.

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

    real

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

    is there no way for us to just copy your code i have to write all of this such a pain

  • @ch3z-m
    @ch3z-m 9 месяцев назад

    3:20 , please give me the full script , like i need it rn , please

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

    Thank you

  • @nandakishorsd6731
    @nandakishorsd6731 3 года назад +1

    plzz your discord server

    • @RootGames
      @RootGames  3 года назад +1

      Hey Nanda, sorry but the discord server is exclusive and available only for people who enrolled in my courses. You can find them on Udemy or Skillshare 🙂

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

      @@RootGames thats really sad :(

    • @RootGames
      @RootGames  3 года назад +1

      ​@@nandakishorsd6731 Don't be sad. Black Friday is coming and courses will be at really affordable prices, even now there are coupons in the description🙂

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

      @@RootGames oh ok then I will be waiting for that! really really waiting for your course to get in my hand XD