Make a 2D TOP-DOWN SHOOTER in just 10 MINUTES (Godot Game Engine)

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • After a long period of inactivity, we're back with a beginner-friendly 10 minute tutorial for a 2D top-down shooter game with Godot!
    Hoping that this could help you out with your game dev journeys. If you liked it, smash that subscribe button and ring that bell! and a "Like" would be appreciated.
    More 10-minute tutorials coming soon! So stay tuned.
    -Elijah
    ========================================
    Music used in this video:
    ➤Otis McDonald / Scarlet Fire
    ➤Otis McDonald / Sneaking on September
    ➤Unicorn Heads / Trip Around the Moon
    ➤Sextile / Purple
    ➤Density & Time / Castlevania
    ========================================
    DISCLAIMER: High change in color (Instantaneous change in brightness/contrast/fast cuts from or to the color red) may cause seizures
    I claim no rights to the music used in this video
    #GameDevelopment #Godot

ความคิดเห็น • 756

  • @randcoding
    @randcoding 4 ปีที่แล้ว +229

    It's wonderful
    but...
    there is a lot of glitches like:
    the Enemies stuck over the walls and they can walk through it when you go so far
    the bullets go in a wrong direction
    the enemies walk very fast in the beginning
    and are you thinking about doing a dash tutorial?

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +97

      Hey! Super sorry for the delay in the response, I have intentionally made the enemies move faster when at a distance and vice versa (personal preference :/). I'm sorry you didn't like it and I didn't expect them to get past through tilemaps due to their increased speed. However, here's an easy fix
      var speed = 3
      func _ready():
      pass # Replace with function body.
      func _physics_process(delta):
      var motion = Vector2()
      var Player = get_parent().get_node("Player")

      motion += (Vector2(Player.position) - position)
      look_at(Player.position)

      motion = motion.normalized() * speed
      move_and_collide(motion)
      Basically, you'd need to determine a variable for speed. put your motion var inside your physics process function and change "position +=" to "motion +=". normalize your motion and multiply the amount to your desired speed. this way the enemy's speed would be normalized and would be constantly hitting the same speed per delta time
      I'm quite worried about having the bullets go in the wrong direction. Could you please describe the bug more?
      Thanks for pointing it out! I'll be making a 2D platformer tutorial up next so I might as well add that dash function!

    • @randcoding
      @randcoding 4 ปีที่แล้ว +28

      @@EliCuaycong thank you very much brother
      about the bullets problem:
      Example: When I in move the mouse on the left of the player (90 degrees) and moving player on the opposite direction (right) if I shoot the bullets seem like they bump into the player and go to the other direction.

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +33

      @@randcoding I think what's happening is that the bullets are colliding with your player body. You can fix this by setting the collision layer of your player to 1, the bullets to 2... and everything else (enemy, tilemaps) to both 1 and 2. Please tell me that you got it fixed! :D

    • @randcoding
      @randcoding 4 ปีที่แล้ว +26

      @@EliCuaycong Thanks, It's work perfectly.
      And I added this to Bullet code:
      |
      func _on_Spell_body_entered(body):
      if "Enemy" in body.name:
      queue_free()
      |
      to make the bullets delete when they touch the enemies
      But It's sometimes didn't work
      And I filed to make they delete when the touch the walls

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +14

      Asgore_Undertale That sounds awesome! You could actually make an object group for both the walls and the enemies. lets say you name the group "environment"
      the code would be
      func_on_spell_body_entered(body):
      if body is_in_group.("environment")
      queue_free()
      (I'm just not sure if i wrote it correctly). The "groups" could be accessed on the node window beside the inspector! hope this works out!

  • @Poafy
    @Poafy ปีที่แล้ว +108

    for everyone who cant find kinematicbody 2D in godot 4 its renamed to characterbody2D

    • @ACTZFilms
      @ACTZFilms 9 หลายเดือนก่อน +5

      this needs to be top comment

    • @mostafar8514
      @mostafar8514 7 หลายเดือนก่อน +4

      you're a hero without a cape, except if you have one

    • @李悦其
      @李悦其 7 หลายเดือนก่อน

      Thanks very much

    • @FiddsOnYou
      @FiddsOnYou 5 หลายเดือนก่อน +1

      You deserve a life of peace. or at least a pinned comment

    • @kilo2492
      @kilo2492 3 หลายเดือนก่อน

      saint

  • @hariharanthegreat5576
    @hariharanthegreat5576 3 ปีที่แล้ว +65

    The light effect makes it all worth it

  • @lemonco7984
    @lemonco7984 3 ปีที่แล้ว +157

    I can't even exaggerate how fast-paced this is, I had to replay the beginning like 7 times

    • @funrush6546
      @funrush6546 3 ปีที่แล้ว +1

      @YODA I stopped counting

    • @oblongLogin
      @oblongLogin 3 ปีที่แล้ว +9

      Put it at 0.75 speed

    • @callum2687
      @callum2687 3 ปีที่แล้ว +1

      @@oblongLogin 0.75! i put a 0.25

    • @almightynoob1631
      @almightynoob1631 ปีที่แล้ว +6

      me who played the video once on 2x: Interesting

    • @BallisticGames005
      @BallisticGames005 7 หลายเดือนก่อน

      Bro u should see mizzizziziziz’s tutorials

  • @thisboathaslegs
    @thisboathaslegs 2 ปีที่แล้ว +62

    0:12 player setup
    1:12 player movement
    2:59 shooting mechanic
    5:21 enemy AI
    7:45 tilemap

  • @user-un2vb8mr6e
    @user-un2vb8mr6e ปีที่แล้ว +35

    For GD Script 2 I changed this line:
    bullet_instance.apply_impulse(Vector2(),Vector2(bullet_speed,0).rotated(rotation))
    to this:
    bullet_instance.linear_velocity = Vector2(bullet_speed,0).rotated(rotation)
    AND
    Enabled Lock_Rotation and set Gravity to 0 in properties panel

  • @Aleksander-_-.
    @Aleksander-_-. 4 ปีที่แล้ว +52

    This is really great work! Love the readability of your code! Please continue making short tutorials like this!

  • @polcomiporcar
    @polcomiporcar ปีที่แล้ว +17

    If you are using a bigger sprite and you are having some bugs while shooting the bullet you might want to change the line where it sets the position of the bullet from this:
    bullet_instance.position = get_global_position()
    to this:
    bullet_instance.position = get_global_position() + Vector2(SPRITE_WIDTH, 0).rotated(rotation)
    changing the "SPRITE_WIDTH" variable to the width of the sprite

    • @nanotheawsome3277
      @nanotheawsome3277 20 วันที่ผ่านมา

      HOLY SHIT DUDE! You have fixed my frustration! I was literally screaming at my monitor "WHY IS MY SPRITE JUST POOPING OUT THE BULLETS?!"

  • @cqsual2047
    @cqsual2047 4 ปีที่แล้ว +18

    I feel like I’m listening to a movie trailer with that voice of yours

  • @olavur123
    @olavur123 4 ปีที่แล้ว +40

    Here's a fun piece of movement code you can try if you want to get rid of the if statements(for some reason).
    motion.x = Input.get_action_strength("right") - Input.get_action_strength("left")
    motion.y = Input.get_action_strength("down") - Input.get_action_strength("up")
    I don't think there are any benefits to this code, though it was fun to figure out.

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +4

      This is cool! Thanks!, more ways to do something is always gonna be better - cheers man 🔥

    • @ZephyrYeti
      @ZephyrYeti 3 ปีที่แล้ว +4

      your a life saver, the if statements didnt work for me

    • @Premiumonkey
      @Premiumonkey 2 ปีที่แล้ว +3

      @@ZephyrYeti Jes, I had the same problem with the If Statenants.

    • @v84l42
      @v84l42 2 ปีที่แล้ว +1

      this is an even more optimized code, though it works for Godot 4 only, but very easy to turn into godot 3
      func _physics_process(_delta):
      var direction = Input.get_vector("A", "D", "W", "S")
      velocity = direction * SPEED
      move_and_slide()
      playerfunctions()

    • @felipekinoshita
      @felipekinoshita 2 ปีที่แล้ว

      There's a shorthand for that, you can use this:
      var input := Vector2(
      Input.get_axis("move_left", "move_right"),
      Input.get_axis("move_up", "move_down")
      )

  • @wackynine
    @wackynine ปีที่แล้ว +12

    If you are using a sprite that SHOULDN'T be upside down when facing the other direction, add these lines of code after your look_at(get_global_mouse_position()):
    if get_global_mouse_position().x < position.x:
    sprite.flip_v = true
    else:
    sprite.flip_v = false
    Edit: forgot to say that at the start of the script you need onready var sprite = get_node("Sprite")

  • @aleksanderbarczak4778
    @aleksanderbarczak4778 4 ปีที่แล้ว +15

    Hello, I would like to say you've made a fantastic tutorial which simultaneously entertained me.
    A little bug within the game exists however, the bullets are affected by gravity and fall to the bottom of the screen, a top down shooter is not supposed to have this behaviour -mechanically speaking- to fix it I would suggest setting the gravity property to zero on the rigidbody root node of the bullet's scene.
    Another thing I found confusing was your method of calculating motion for the enemies ( Just sharing thoughts here, not an attack or something) using the difference between the player and enemy can give a vector to then normalize and then use with a speed either calculated or static.
    The variable could be used in a move and slide i instead of manually altering position and using move and collide, the latter of which could make enemies glitch through one another and through walls.
    Apart from that I loved your tutorial and hope to see more

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +2

      Hey! Thanks for pointing these out - gotta use these as reference soon. Definitely helps in learning. Thanks for the feedback! much appreciated

  • @antoniody8329
    @antoniody8329 4 ปีที่แล้ว +22

    Tutorial Suggestion: How to add sounds on actions like walking sound and jump sound etc stuff.

  • @juanignaciogilbordon1935
    @juanignaciogilbordon1935 2 ปีที่แล้ว +2

    I've chacked the comments and i didn't saw anyone with my problem.
    My problen is that when i die, the bullets i shooted in the previous game are still there, and you can barely see them, but when enemys collide with those "ghost bullets" they die, can someone help me pls

  • @biirdman89
    @biirdman89 4 ปีที่แล้ว +15

    Amazing channel dude. Thanks for not doing using fancy programming functions and keeping it as simple as possible. Extremely helpful channel

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +4

      Comments like these keep me going - I'm new to programming as well, and I'm trying to make everything as easy as possible that newbies can follow. Thank you so much!

    • @poragpro5818
      @poragpro5818 ปีที่แล้ว +1

      @@EliCuaycong the skript shoos an eroor at motion = motion.normalized() what do i do?

  • @buu_ruh3547
    @buu_ruh3547 4 ปีที่แล้ว +5

    can someone help me please?
    the bullets come out of my mouse instead of the player
    nevermind, i found out that i typed get_global_MOUSE_position instead of get_global_position

  • @_j-lv7zj
    @_j-lv7zj 4 ปีที่แล้ว +14

    godot is complicated but i think i will get the hang of it

  • @point2homes14
    @point2homes14 4 ปีที่แล้ว +34

    Did it and is amazing, however noticed that the bullets sometimes go through the tiles, why's that happening?

    • @mleitejunior
      @mleitejunior 4 ปีที่แล้ว +1

      Me too and can't figure out

    • @averiWonBTW
      @averiWonBTW 4 ปีที่แล้ว +10

      It’s because the bullet moves so fast that it skips past the tile within a frame. Either decrease the bullet speed or use ray-casts instead.

    • @julesnicolsontabuno2550
      @julesnicolsontabuno2550 4 ปีที่แล้ว +8

      You can add the tiles to a 'group' , and add a node to the bullet called 'on area entered'. Once the bullet collides with that group(the tiles), you can use the function 'queue_free()' to make them disappear, making the bullets not pass through tiles.

  • @happyeddy317
    @happyeddy317 3 ปีที่แล้ว +1

    i am having a trouble, i trinying to make it folllow the player but the moment i move trowards the enemy it moves away

  • @micha7349
    @micha7349 3 ปีที่แล้ว +3

    im having trouble with the shooting. i did it as in the tutorial and i have no errors, but it just dosent work and i cant figure out why

    • @aleee_6417
      @aleee_6417 3 ปีที่แล้ว

      can you shoot while you stand still?

  • @duckyy8655
    @duckyy8655 ปีที่แล้ว +3

    Does it work in godot4 too idk why but the bullets don't move :( edit i fixed it but it's more like a work around tho

  • @TimKrief
    @TimKrief 4 ปีที่แล้ว +24

    Thanks for spreading godot knowledge. As a full-time user, I truly think godot is underestimated 😊

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +7

      I haven't tried any other game engines and I learned coding for the first time in Godot! Completely beginner friendly and super intuitive, hoping this engine would make it big

    • @dopedrums
      @dopedrums 3 ปีที่แล้ว

      Hardly underestimated, just not that known.

    • @ghostofathens6600
      @ghostofathens6600 3 ปีที่แล้ว

      @@EliCuaycong can you make a menu for this game?

  • @ljinfinity8301
    @ljinfinity8301 3 ปีที่แล้ว +3

    how do i solve this error
    Invalid call. Nonexistent function 'apply_impulse' in base 'Node2D'.

    • @jeffrax1631
      @jeffrax1631 3 ปีที่แล้ว

      pls help i have the same error

  • @MadMaxBLD
    @MadMaxBLD 4 ปีที่แล้ว +6

    Amazing, G-Man doing a Godot tutorial!

  • @issac3487
    @issac3487 3 ปีที่แล้ว +2

    >| bullet_instance.apply_impulse(Vector2(),Vector2(bullet_speed,0).rotated(rotation))
    I wrote this but it says error plz help

    • @Dines646
      @Dines646 3 ปีที่แล้ว

      Yeah same :/

  • @KryFuZe
    @KryFuZe 2 ปีที่แล้ว

    my bullets spray out super fast, what did I do wrong?

    • @Alt1-t8r
      @Alt1-t8r 2 หลายเดือนก่อน

      Change it to is_action_just_pressed insted of is_action_pressed

  • @HUARASTACA
    @HUARASTACA 3 หลายเดือนก่อน +1

    In case you get (Invalid call. Nonexistent function 'instance' in base 'PackedScene'.) error u should change instance() to instantiate()

    • @DreadfulDiction
      @DreadfulDiction 2 หลายเดือนก่อน +1

      You absolute legend

  • @DcYhL
    @DcYhL ปีที่แล้ว +2

    Hey, great video, but I have a problem. Everything else is working, but the thing is that when the bullet hits the enemy, the enemy doesn't disappear. Please help!

    • @GastLordYT
      @GastLordYT ปีที่แล้ว +1

      I found a video that fixed this , let me link it in a another comment but how did you fix the tileset stuff? Anytime I drag my tileset as a tres over it says “The selected resource ( Mesh-library ) does not match any type expected for this property (tres) “ but the file is a .tres file. I’m in Godot 4

  • @Road_to_Dawn
    @Road_to_Dawn หลายเดือนก่อน

    I realize this is an old video and no longer in date for Godot, but this was extremely helpful and brought me an epiphany for my own game. I want the player to have an arrow rotating around their character sprite showing the position of the mouse cursor relative to them. But the problem was that for some reason, the arrow kept going off on its own and leaving the player behind. Watching you, I realized that I could just have the arrow BE the player, and the character sprite would just be a picture attached to the player. And since I want to have many playable characters, each with their own stats, the character sprite would just be another one of the variables that gets swapped out every time you change characters.

  • @eshanrahim
    @eshanrahim 11 หลายเดือนก่อน +2

    hi just trying to figure something out but appararently during the player movement the code appears as an Error: motion = move_and_slide(motion * movespeed)
    if you know anything about it relay back to the comment if not its still ok

    • @juggle-helmet5634
      @juggle-helmet5634 10 หลายเดือนก่อน +1

      its now move_and_collide not move_and_slide

  • @_Garm_
    @_Garm_ 4 ปีที่แล้ว +24

    Really liked it! , but it did not take me 10 min more like an hour :P when i re-watched it while following along, i noticed quite a lot of details i have missed first time around :D great tutorial thank you! :D

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +4

      Glad to have helped you out! Thank you as well

    • @fingorchipz8662
      @fingorchipz8662 3 ปีที่แล้ว

      @@EliCuaycong when are you making another tutorial?

    • @juanignaciogilbordon1935
      @juanignaciogilbordon1935 2 ปีที่แล้ว

      @@fingorchipz8662 he quit his channel :(

    • @qrisquinn
      @qrisquinn 2 ปีที่แล้ว

      @@juanignaciogilbordon1935 Just because he hasn't uploaded in a little while, doesn't mean that he quit his channel.

  • @TIMMusic12398
    @TIMMusic12398 3 หลายเดือนก่อน +1

    I have trouble understanding this line can anyone explain for me
    func fire():
    var bullet_instance = bullet.instance()
    bullet_instance.position = get_global_position()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse(Vector2(),Vector2(bullet_speed, 0).rotated(rotation))
    get_tree().get_root().call_deferred("add_child",bullet_instance)

  • @yousif07
    @yousif07 2 ปีที่แล้ว +1

    Hello, show me this message error(10,2): Error parsing expression, misplaced: if

  • @xgozulx
    @xgozulx 4 ปีที่แล้ว +15

    Im copiing everything by hand as a practice tool, im learning a lot, so thanks

  • @ServentofTheMostMerciful
    @ServentofTheMostMerciful 3 ปีที่แล้ว +1

    How do i put max speed? I just need to make sure that my enemies are not zooming through the walls when they are fast.

    • @ServentofTheMostMerciful
      @ServentofTheMostMerciful 3 ปีที่แล้ว

      Here is the code:
      func _physics_procces(delta):
      var player = get_parent().get_parent().get_node("Player")
      position += (player.position - position)/80
      sprite.flip_h = move.x < 0
      move = move_and_slide(move, Up)

  • @azuackprz4216
    @azuackprz4216 ปีที่แล้ว +1

    all works but the thing is the bullet goes down and not actually shooting, i tried to turn off gravity on the rigidbody2d but it just go up, i also tried to chance the linear_velocity but nothing changed please help me

  • @crystalxgaming8218
    @crystalxgaming8218 ปีที่แล้ว +1

    My
    Motion = move_and_slide(motion * movespeed) is showing error
    Too many arguments for "move_and_slide" Call. Expected at most 0 but received 1.
    Help me fix this

    • @babybabster
      @babybabster ปีที่แล้ว

      change "move_and_slide" to "move_and_collide", move and slide function is cut in last versions of Godot

    • @crystalxgaming8218
      @crystalxgaming8218 ปีที่แล้ว

      @@babybabster I will try thx

    • @Valican11
      @Valican11 10 หลายเดือนก่อน

      @@babybabster doesnt work

  • @philkyaw9479
    @philkyaw9479 2 ปีที่แล้ว +3

    Epic vid!
    There is gravity applied to the bullets, which probably should happen in a top down game. A gravity scale on the RigidBody2D should help avoid that

  • @sircorndog9647
    @sircorndog9647 3 ปีที่แล้ว +1

    The bullet spawns at the mouse and not the player position, any fixes?

    • @juanignaciogilbordon1935
      @juanignaciogilbordon1935 2 ปีที่แล้ว

      same happened to me!
      here is the solution
      you are putting get_global_mouse_position() in the bullet part
      change it to get_global_position()

  • @JoshuaVargas-wd6je
    @JoshuaVargas-wd6je 5 หลายเดือนก่อน +2

    It doesnt let me put anything inside the parenthesis of move_and_slide inside the player

    • @DeavtheDev
      @DeavtheDev 4 หลายเดือนก่อน

      Same, I think cause it's old pretty sure you don't need it

    • @TokarevTokarevTokarev
      @TokarevTokarevTokarev 3 หลายเดือนก่อน

      use move_and_collide instead, worked for me

  • @ihp-minecraft7991
    @ihp-minecraft7991 4 ปีที่แล้ว +4

    dude u can use the grid snap proprety to make the light accluder polygons, it automaticly sets the positions for you wich makes it way eisier to draw the polygons

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +1

      Hey! Thanks for pointing this out - This is awesome! Great tip

  • @sangeeta3729
    @sangeeta3729 3 ปีที่แล้ว +1

    Whenever i try to shoot godot lags and stop working i tried many times
    Please tell the solution

  • @Leux64
    @Leux64 18 วันที่ผ่านมา

    If your bullet is spawning inside your character and causing some hitbox issues, try that.
    X = The number of pixels you want the bullet to spawn away from your character.
    var offset_distance = X
    bullet_instance.position = get_global_position() + Vector2(offset_distance, 0).rotated(rotation)
    Instead of
    bullet_instance.position = get_global_position()

  • @leonelfagereng2336
    @leonelfagereng2336 3 ปีที่แล้ว +3

    Whenever I try to shoot the game stops and an error comes up. It says: Invalid call. Nonexistent function 'instance' in base 'GDScript' then it points to this line in the script: var bullet_instance = bullet.instance()

  • @nucleus5191
    @nucleus5191 3 ปีที่แล้ว

    bro, why the enemy is not following the player properly? like, the enemy stucks in the wall. can i do anything which can make the enemy follow the player nicely?

  • @juli_ariawan234
    @juli_ariawan234 3 ปีที่แล้ว

    Someone help me i have a problem with the shooting , why my bullet is bursting like a machine gun every click the lmb

  • @raajubontha
    @raajubontha 3 ปีที่แล้ว +1

    why this error is comming
    modules/gdscript/gdscript_tokenizer.cpp:1129 - Condition "tk_rb[ofs].type != TK_IDENTIFIER" is true. Returned: StringName()

  • @kleydermendoza4771
    @kleydermendoza4771 4 ปีที่แล้ว

    Hello, please, I need help, I have an error when I try to shoot, it tells me that the add child method does not exist, this is my code
    * Disparar It's shooting in Spanish
    if Input.is_action_just_pressed ("MCD"):
    disparar()
    func disparar():
    var bullet_instance = bullet.instance ()
    bullet_instance.position = get_global_position ()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse (Vector2 (), Vector2 (bulletspeed, 0) .rotated (rotation))
    get_tree (). get_root (). call_deferred ("add child", bullet_instance)

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว

      My apologies for not being able to respond on time - hoping this issue has been fixed; if not, have you set a variable for "var bullet" to preload an instance of your bullet scene?
      I could see nothing wrong with the code you pasted though

  • @medosfilms
    @medosfilms 4 ปีที่แล้ว +1

    hey, my player and enemey are stuck in the top left of the screen, theyre colliding, and whern they collide it reloads, and so i cant play cus theyre stuck colliding. what can i do, is there a way i can make the player start in a randomized place and the enemies in a randomized place?

    • @SaturdayXIII
      @SaturdayXIII 4 ปีที่แล้ว +1

      I know I'm late, but I just had the same problem and haven't seen an answer here. Click the "Player" kinematicbody node, then in "inspector" on the right there's a drop down called "transform". Enter some numbers in the "position" boxes. I did 300 in both x and y to give my player some space from the enemy.

    • @medosfilms
      @medosfilms 4 ปีที่แล้ว

      @@SaturdayXIII thank you brother

  • @lavadudestudios380
    @lavadudestudios380 3 ปีที่แล้ว

    I don't know why this happened but my enemy and player have merged and nothing is working😭😭😭

  • @Coffeelipe_
    @Coffeelipe_ 2 ปีที่แล้ว

    I have a problem where my bullets just go straight through the enemies and don't kill them. I can't see where I've messed up.

  • @kaungkaung8320
    @kaungkaung8320 3 ปีที่แล้ว

    it makes a huge help but how to make my bullets disappear they are just floating even it touch with the enermy

  • @DiegoSilva-bp9if
    @DiegoSilva-bp9if 2 ปีที่แล้ว

    more than two years later I find your video, and your channel. thanks.

  • @PastaMaster115
    @PastaMaster115 3 หลายเดือนก่อน

    I got it working, despite the version difference. But I want to know if anyone added recoil on firing. If so, how did you do it? I'm trying to use the rotation of the player sprite and add backwards velocity. I feel like I'm right on the edge of figuring it out but it's just not working.

  • @VirtuallyTher3
    @VirtuallyTher3 3 ปีที่แล้ว +1

    when i move i dont slide around i just kinda slightly move 2 frames a second
    \

    • @sum241
      @sum241 3 ปีที่แล้ว

      same problem

    • @VirtuallyTher3
      @VirtuallyTher3 3 ปีที่แล้ว

      @@sum241 i found the solution you just have to restart the software

    • @sum241
      @sum241 3 ปีที่แล้ว

      @@VirtuallyTher3
      edited code worked for me:
      if Input.is_action_just_pressed("up"): -----> if Input.is_action_pressed("up"):

  • @ZakoR8
    @ZakoR8 2 ปีที่แล้ว

    hey because I do not work shooting but I typed everything correctly. if anyone knows how it please tell me what I'm doing wrong

  • @infernojoe
    @infernojoe ปีที่แล้ว +1

    the bullet does not shoot out. apply_impulse does not work.

  • @cocoarecords
    @cocoarecords 4 ปีที่แล้ว +3

    loved this actually

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว

      Glad you liked it! Thank you 🔥

  • @shanujha7245
    @shanujha7245 3 ปีที่แล้ว +1

    aight, i'm at 5:44 . Imma continue this tomorrow. Thanks for the tut.

  • @DrJoe-sm9no
    @DrJoe-sm9no 4 ปีที่แล้ว +6

    I tried the apply_impulse() function before, and for some reason it said it wasn't an existing function. Anyone got any ideas on how I could fix that?

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +4

      Hmmm, I'm not really sure what's causing the issue - but it has got me into thinking that you may haved used a different body type for the bullet. Rigidbodies are the only bodies that have "apply_impulse" as an in built function, the bullet should be a rigid body in this case.
      I'm hoping this helps! please tell me if it works!

    • @tommasobassignana1943
      @tommasobassignana1943 4 ปีที่แล้ว +3

      @@EliCuaycong It's the right answer, just redo the bullet scene making sure that the first node it's a rigidbody and not a Node2D, also, the fact that you respond to every question it's amazing! keep it up!

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว

      @@tommasobassignana1943 That's awesome - hoping you'd make that game big! Cheers!

    • @kimojumamil6121
      @kimojumamil6121 4 ปีที่แล้ว

      @@tommasobassignana1943 I had this problem too :)

    • @roopaish
      @roopaish 3 ปีที่แล้ว

      @@EliCuaycong wow mine was kinetic body , so it didn,t work. Thanks

  • @kleydermendoza4771
    @kleydermendoza4771 4 ปีที่แล้ว

    4:35 hey help please, it tells me an error "_call _function": Error calling deferred method: 'viewport :: add child': Method not found, this is my code
    * "disparar", is "shot" in spanish
    if Input.is_action_just_pressed("MCD"):
    disparar()
    func disparar():
    var bullet_instance = bullet.instance()
    bullet_instance.position = get_global_position()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse(Vector2(),Vector2(bulletspeed, 0).rotated(rotation))
    get_tree().get_root().call_deferred("add child" ,bullet_instance)

  • @janousekpetr6843
    @janousekpetr6843 9 หลายเดือนก่อน

    If adding points is not working during setting-up of the LightOccluder2D, you might have switched from "Select mode" (arrow icon in the same panel) to Move or Scale or other mode previously. You have to keep the Select mode active for adding the points to work properly.

  • @Opineusz9231
    @Opineusz9231 3 ปีที่แล้ว

    Bruh I've been doing the tutorial step by step but I Cant play the game as it's shown in a tutorial I cant see no preview I cannot do anything there is just a black square when I start

  • @GrenjaGaming
    @GrenjaGaming 3 ปีที่แล้ว

    i was following through for practice and something in the var movespeed = 500 my game engine is constantly showing error in that line

  • @theinfohacker
    @theinfohacker 4 ปีที่แล้ว +3

    So what I'm getting from this is that you'll be switching to more "tutorial" based content from now on rather than continuing your devlogs or will you try jugling both at the same time?:)

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +1

      More content would always be better! Yes, I'll be doing both devlogs and tutorials - I was actually working on my next devlog video, but somehow sidetracked to this tutorial since l'm currently hitting the harder parts in my gamedev journey 😆

  • @xevlos6578
    @xevlos6578 3 ปีที่แล้ว

    folks, i need help, when i write:
    fire func ():
    var bullet_instance = bullet.instance ()
    bullet_instance.position = get_global_position ()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse (Vector2 (), Vector2 (bullet_speed) .rotated (rotation))
    get_tree (). get_root (). call_deferred ("add_child", bullet_instance)
    it tells me "invalid call. There is no VECTOR2 constructor" How do I solve it?

    • @mrclips321
      @mrclips321 3 ปีที่แล้ว

      copy and paste this
      func fire():
      var bullet_instance = bullet.instance()
      bullet_instance.position = get_global_position()
      bullet_instance.rotation_degrees = rotation_degrees
      bullet_instance.apply_impulse(Vector2(),Vector2(bullet_speed,0).rotated(rotation))
      get_tree().get_root().call_deferred("add_child",bullet_instance)

    • @xevlos6578
      @xevlos6578 3 ปีที่แล้ว

      @@mrclips321 Unexpected indetation.

  • @rolandpalmer7125
    @rolandpalmer7125 3 ปีที่แล้ว

    Okay am I stupid? How do you make it so you dont walk through the walls? I feel like thats never said here but no one else seems to have that problem

  • @Admpdf
    @Admpdf 4 ปีที่แล้ว +3

    Can you copy and paste the script in the description pks

  • @gamalielrumahpasal7995
    @gamalielrumahpasal7995 2 ปีที่แล้ว

    my bullet stuck on coordinate 0,0 so everytime i shot its just shot at 0,0

  • @enzomontage4130
    @enzomontage4130 2 ปีที่แล้ว +1

    hello, I have a strange question. where can I find a 16*16 white square

  • @MaskedRokho
    @MaskedRokho 3 ปีที่แล้ว

    When my bullet hits some parts of the wall it bounces, but if it hits other parts of the same wall, it doesn't bounce. Also when I'm turning while shooting my bullets they skew to where I was shooting at before. Say I turn counter-clockwise while shooting, the bullets skew in the clockwise direction. Can anyone help?

  • @techfactz3213
    @techfactz3213 3 ปีที่แล้ว

    I cannot move the player it's fixed in the corner of the DEBUG window :/ Can anyone suggest me what to do??

  • @swapankumarchowdhury1491
    @swapankumarchowdhury1491 3 ปีที่แล้ว

    it's showing nonexistent function "call_deffered" is base viewport when pressing left click to shoot...what to do?

  • @ladnjb1457
    @ladnjb1457 ปีที่แล้ว

    bruh this is the best game dev learning channel out there thx man for ur time

  • @wolfystrider
    @wolfystrider 4 ปีที่แล้ว

    The fire function isnt working! Please help. I'm just getting this error E 0:00:00.582 get_token_identifier: Condition "tk_rb[ofs].type != TK_IDENTIFIER" is true. Returned: StringName()
    modules/gdscript/gdscript_tokenizer.cpp:1129 @ get_token_identifier()

  • @fernanboxfrias381
    @fernanboxfrias381 4 ปีที่แล้ว +2

    Can you explain me why my code is not correct. it says that fire isn't declared in the current class. Minute 5:00. THis is my code: extends KinematicBody2D
    var movespeed = 500
    var bullet_speed = 2000
    var bullet = preload("res://bullet.tscn")
    func _ready():
    pass
    func _physics_process(_delta):
    var motion = Vector2()
    if Input.action_pressed("up"):
    motion.y -= 1
    if Input.action_pressed("down"):
    motion.y += 1
    if Input.action_pressed("right"):
    motion.x += 1
    if Input.action_pressed("left"):
    motion.x -= 1
    motion = motion.normalized()
    motion = move_and_slide(motion * movespeed)
    look_at(get_global_mouse_position())
    if Input.is_action_just_pressed("LMB"):
    fire()
    func _fire():
    var bullet_instance = bullet.instance()
    bullet_instance.position = get_global_mouse_position()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse(Vector2(), Vector2(bullet_speed,0).rotated(rotation))
    get.tree().get.root().call.deferred("add_child", bullet_instance)

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +1

      Its with the fire function! It seems that you have called fire() on the if statement
      the function that you have declared has an underscore _fire()
      i believe we can fix this by doing:
      If Input.is_action_just_pressed("LMB"):
      _fire()
      Hope this helps! Thanks for watching - keep it up!

    • @fernanboxfrias381
      @fernanboxfrias381 4 ปีที่แล้ว +1

      Please respond

    • @williamjav1er921
      @williamjav1er921 4 ปีที่แล้ว

      @@fernanboxfrias381 this is the problem: get.tree().get.root().call.deferred("add_child", bullet_instance) - get_tree().get_root() instead of get.tree().get.root()-

    • @williamjav1er921
      @williamjav1er921 4 ปีที่แล้ว

      and *get_tree().get_root().call_deferred("add_child", bullet_instance)* instead of get_tree().get_root().call.deferred("add_child", bullet_instance)

  • @ismaelmovies
    @ismaelmovies 4 ปีที่แล้ว +1

    Can't make it to fire - Rigidbody2d- sprite-collitionshape done
    code:
    if Input.is_action_just_pressed("LMB"):
    fire()

    func fire():
    var bullet_instance = bullet.instance()
    bullet_instance.position = get_global_position()
    bullet_instance.rotation_degrees = rotation_degrees
    bullet_instance.apply_impulse(Vector2(), Vector2(bullet_speed, 0).rotated(rotation))
    get_tree().get_root().call_deferred("add child",bullet_instance)


    func kill():
    get_tree().reload_current_scene()
    func _on_Area2D_body_entered(body):
    if "Enemy" in body.name:
    kill()
    What I am doing wrong?

  • @mystikk3025
    @mystikk3025 2 ปีที่แล้ว

    4:35 is it just me or does the 28 line code doesn't Work?
    It has the ,,the identifier ,,bullet" isn't declared in the current scope"
    Any help on what to do?

  • @lDerpedl
    @lDerpedl 2 ปีที่แล้ว

    I need some help. I am at around 6:30 I have my code the same way, yet it's saying "The identifier "position" isn't declared in the current scope." I've been hard staring at it to see if I miss spelled anything.

    • @FIRE_GAMERZ-777
      @FIRE_GAMERZ-777 2 ปีที่แล้ว

      Just change the Player to small player I hope you understand

  • @crowofjudgement3682
    @crowofjudgement3682 3 ปีที่แล้ว +1

    Hey uhh I need help
    So when I move like I press w it goes one tile and stops immediately it's not sliding like yours?

    • @unworthy.potato
      @unworthy.potato 3 ปีที่แล้ว

      Crow of judgement do you have move and slide or move and collide for the player code? It should be move and slide

    • @bxspew7683
      @bxspew7683 2 ปีที่แล้ว

      did you check about "is_action_pressed" and not "is_action_just_pressed"

  • @soL1dcsgo
    @soL1dcsgo 2 ปีที่แล้ว

    I got an error: Nonexistant function 'apply_impulse' in base Node2D. I checked, all the code is right, but still I can't shoot

    • @yuukil5522
      @yuukil5522 2 ปีที่แล้ว

      you have to make sure the base node is the rigidbody, that will let you shoot. However, you will still have a bug: the bullet will be huge and collide with you. That is because of a bug in rigidbody2d, so you may want to check out a different tutorial :)

  • @mlody4ever
    @mlody4ever 3 ปีที่แล้ว

    Please help.
    Kill function isn't working and the whole game is reloading sceene over and over again.
    How do I fix this?

    • @virtuallemon4224
      @virtuallemon4224 3 ปีที่แล้ว

      is an enemy spawning inside the player

    • @mlody4ever
      @mlody4ever 2 ปีที่แล้ว

      @@virtuallemon4224 no

  • @bnkm07
    @bnkm07 2 ปีที่แล้ว +1

    how to make respawning enemies so i can make the game arcade style with scores and stuff like that

  • @humanrainbowdash8101
    @humanrainbowdash8101 4 ปีที่แล้ว +2

    i somehow can not draw the polygons of the light occluder. I did all steps as you mentioned but when I try to draw the polygons, there are no lines shown :(

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว +1

      That sounds odd... I'm not really quite sure what's causing the issue. Try to make sure that you're clicking on the LightOccluder node, then create an occluder shape to draw on. And click the green button to draw the points. Please tell me if it does work out!

    • @humanrainbowdash8101
      @humanrainbowdash8101 4 ปีที่แล้ว +1

      @@EliCuaycong Thanks for answering! So I watched the video again, to make sure I did not make any mistakes and it seems like I can not click the green button that would let me create the points for the polygons. If I click on it, it becomes green, but once I stop pressing down on the mouse, it turns blue again. In conclusion: The button is not being activated. I couldnt figure out any shortcuts to use instead of the green button :/

    • @EliCuaycong
      @EliCuaycong  4 ปีที่แล้ว

      hey! I actually tried it myself and I realized it works without even clicking the green button. Just create the new occluder shape button and click directly on where you'd like to start drawing your shape.

    • @Alex-e-Azam
      @Alex-e-Azam 4 ปีที่แล้ว

      @@EliCuaycong No, it does not draw anything for me. Yes, I did everything EXACTLY the way in vid

    • @Alex-e-Azam
      @Alex-e-Azam 4 ปีที่แล้ว +1

      It worked! Apparently you need to click on Polygon under Occluder to start changing it

  • @StarlightGippy
    @StarlightGippy 3 ปีที่แล้ว

    so i believe i typed everything correctly but i keep getting an error saying bullet isnt declared in the current scope

    • @StarlightGippy
      @StarlightGippy 3 ปีที่แล้ว

      func fire():
      var bullet_instance = bullet.instance()
      bullet_instance.postion = get_global_position()
      bullet_instance.rotation_degrees = rotation_degrees
      bullet_instance.apply_impulse(Vector2(),Vector2(bullet_speed,0).rotated(rotation))
      get_tree().get_root().call_deferred("add_child",bullet_instance)

    • @virtuallemon4224
      @virtuallemon4224 3 ปีที่แล้ว

      @@StarlightGippy try this
      var bullet = preload("res://Bullet/Bullet.tscn")
      func fire():
      var bullet_instance = bullet.instance()
      bullet_instance.get_global_transform()
      bullet_instance.position = position
      bullet_instance.rotation_degrees = rotation_degrees
      bullet_instance.apply_impulse(Vector2(),Vector2(bulletspeed,0).rotated(rotation))
      get_tree().get_root().call_deferred("add_child",bullet_instance)

    • @StarlightGippy
      @StarlightGippy 2 ปีที่แล้ว

      after a year i did it

  • @YoussCR7
    @YoussCR7 3 ปีที่แล้ว +1

    Hey I have a problem , when i put var bullet = preload("res://Bullet.tscn") it gives me an error that says: Can't preload source at path : res://Bullet.tscn , how do I fix It ?

    • @farkler4785
      @farkler4785 3 ปีที่แล้ว

      I'm a bit late but your capitalization might be wrong, make sure that your file name is the same as what you're putting in the preload, if you're bullet is lowercase it will give an error.

  • @Gamedev00100
    @Gamedev00100 3 ปีที่แล้ว

    i like it a lot specially after finishing the tutorial the music and excitement made me dance like i lost it.

  • @mitick_p
    @mitick_p 2 ปีที่แล้ว

    help, for some reason my movement is skipping rather tah smooth, by means, it not as smooth as yours, its like its teleporting, even though we have the same movespeed, and motion.

  • @McHale09
    @McHale09 3 ปีที่แล้ว

    I did everything you did but Im getting an error when I fire. fire() and bullet_instance.postiion = get_global_position() are being flagged for some reason

    • @juanignaciogilbordon1935
      @juanignaciogilbordon1935 2 ปีที่แล้ว

      you misplelled bullet_instance.postiion change it to bullet_instance.position

  • @abvoltbolt
    @abvoltbolt 2 ปีที่แล้ว

    I'm getting a strange error when I attach the area 2d n the player and input the function you put there, it's throwing the error (invalid call. nonexistent function 'name' in base 'kinematicbody2d (player.gd) not sure how to fix this. I have the exact same code as in the video so idk what is going wrong.

    • @abvoltbolt
      @abvoltbolt 2 ปีที่แล้ว

      nevermind I found the problem

  • @pancakerabbit3889
    @pancakerabbit3889 3 ปีที่แล้ว +6

    the fast pace is what made me stay. even if I have to pause, I die of boredom and lose all interest when it's not at a convenient speed. thanks for being great !

    • @thesyndicatea.t.k7528
      @thesyndicatea.t.k7528 3 ปีที่แล้ว

      hey could u please help me with smth in this vid, u seem to have understood everything right?

    • @GelleSzebasztian
      @GelleSzebasztian 2 ปีที่แล้ว +1

      Same with me. I suffer a lot pausing and rewinding. But this suffering is still much much less, than those boring long 1 hour tutorials...

  • @theinfinitynoob8970
    @theinfinitynoob8970 3 ปีที่แล้ว

    i was doing the walking code and i got stuck, when you showed in functioning i was stuck with a still sprite, this is my code if it helps: extends KinematicBody2D
    var movespeed = 5
    func _ready():
    pass # Replace with function body.
    func delta_physics_process(delta):
    var motion = Vector2()

    if Input.is_action_pressed("up"):
    motion.y -= 1
    if Input.is_action_pressed("down"):
    motion.y += 1
    if Input.is_action_pressed("right"):
    motion.x += 1
    if Input.is_action_pressed("left"):
    motion.y -= 1

    motion = motion.normalized()
    motion = move_and_slide(motion * movespeed)
    any idea what's wrong?

  • @JellyIce1421
    @JellyIce1421 2 ปีที่แล้ว +1

    Just another way for movement try it out maybe you would like it....
    export (int) var speed = 300
    var velocity = Vector2()
    func get_input():
    look_at(get_global_mouse_position())
    velocity = Vector2()
    if Input.is_action_pressed("down"):
    velocity = Vector2(-speed, 0).rotated(rotation)
    if Input.is_action_pressed("up"):
    velocity = Vector2(speed, 0).rotated(rotation)
    func _physics_process(delta):
    get_input()
    velocity = move_and_slide(velocity)

    • @Autonova
      @Autonova 2 ปีที่แล้ว

      This saved me, thanks a lot. Got an error with the method used in the video for some reason - "expected end of var, got built in type instead"

  • @juangabrielcallaanco8856
    @juangabrielcallaanco8856 3 ปีที่แล้ว

    Who can help me once I put play at minute 2:29 (I'm in that minute) I get the following error: (is_action_pressed: request for nonexistent Inputmap action right) what should I do? I tried to solve it but nothing

    • @z1ffy
      @z1ffy 3 ปีที่แล้ว

      In your project, at the top left click project, then project settings, input map, and at the top write "right" and then it will add to the input map. then at the bottom there will be a plus to the very right side of the word "right". press than, press key, then press D or whatever you want to use to go right

  • @Fropaa
    @Fropaa 3 ปีที่แล้ว

    i have a problem with the shooting when i shoot the opposite direction from the players mouvment direction the bullet just acts weerd idk

  • @acedefective2220
    @acedefective2220 ปีที่แล้ว +2

    the bullets fall down after like they have gravity. does anyone know how I would fix this

    • @gamingavinash3173
      @gamingavinash3173 ปีที่แล้ว

      Hey buddy, can you send me the download link of 16*16 pixel square png

    • @nyoho5554
      @nyoho5554 ปีที่แล้ว

      ​@@gamingavinash3173 bro just make one

    • @nyoho5554
      @nyoho5554 ปีที่แล้ว +1

      Having the same issue

    • @nyoho5554
      @nyoho5554 ปีที่แล้ว +2

      Yes, the fix is to remove gravity on the rigid body's. Also, instead of using apply_impulse I'd use linear_velocity.

  • @ExplosivePine
    @ExplosivePine 3 ปีที่แล้ว

    i need help with something if anyone is wiling to help. I wanted to make a shotgun as a different alternative to firing. so what i did was i changed the rotation of the bullets to this -60 -30 0 +30 +60 . now what happens is when i shoot the bullets explode in every direction around me. I think theyre colliding with each other and the player. what do i do?

    • @ExplosivePine
      @ExplosivePine 3 ปีที่แล้ว

      var shotgun1_instance = shotgun1.instance()
      shotgun1_instance.position = get_global_position()
      shotgun1_instance.rotation_degrees = rotation_degrees
      shotgun1_instance.apply_impulse(Vector2(),Vector2(shotgun_speed,0).rotated(rotation))
      get_tree().get_root().call_deferred('add_child',shotgun1_instance)
      var shotgun2_instance = shotgun2.instance()
      shotgun2_instance.position = get_global_position()
      shotgun2_instance.rotation_degrees = rotation_degrees - 30
      shotgun2_instance.apply_impulse(Vector2(),Vector2(shotgun_speed,0).rotated(rotation-30))
      get_tree().get_root().call_deferred('add_child',shotgun2_instance)
      var shotgun3_instance = shotgun3.instance()
      shotgun3_instance.position = get_global_position()
      shotgun3_instance.rotation_degrees = rotation_degrees + 30
      shotgun3_instance.apply_impulse(Vector2(),Vector2(shotgun_speed,0).rotated(rotation+30))
      get_tree().get_root().call_deferred('add_child',shotgun3_instance)
      var shotgun4_instance = shotgun4.instance()
      shotgun4_instance.position = get_global_position()
      shotgun4_instance.rotation_degrees = rotation_degrees - 60
      shotgun4_instance.apply_impulse(Vector2(),Vector2(shotgun_speed,0).rotated(rotation-60))
      get_tree().get_root().call_deferred('add_child',shotgun4_instance)
      var shotgun5_instance = shotgun5.instance()
      shotgun5_instance.position = get_global_position()
      shotgun5_instance.rotation_degrees = rotation_degrees + 60
      shotgun5_instance.apply_impulse(Vector2(),Vector2(shotgun_speed,0).rotated(rotation+60))
      get_tree().get_root().call_deferred('add_child',shotgun5_instance)
      heres what i did i just repeated it five times

  • @tehbeanz5062
    @tehbeanz5062 3 ปีที่แล้ว

    Please could you help me with a problem I have:
    When I try to shoot it crashes the game and gives me these errors:
    It gives me an error on the line where you use the apply_impulse function
    and one on the line where you call the fire function?
    Please could you help?

  • @webhead139
    @webhead139 4 ปีที่แล้ว

    @Eli Cuaycong when I press the left mouse button to fire, the entire game freezes. I cant move nor does the player sprite look at the mouse. I am currently at 5:08

  • @jerryjohnthomas4908
    @jerryjohnthomas4908 3 ปีที่แล้ว

    Light2d's light is not displaying when we r hitting against a black static box, any idea how to fix