Godot 3.0: Top-down Tank Battle - Part 4

  Рет қаралды 35,764

KidsCanCode

KidsCanCode

6 жыл бұрын

Welcome to a new tutorial series. Many of you have requested a full game tutorial, so I've chosen a top-down tank game. I have no idea how many parts this will be, but as we go we'll cover things like tilemaps, pathfinding, ai/behavior, and many other topics.
Art by Kenney: kenney.nl/assets/topdown-tanks...
Follow the written version of the series here:
kidscancode.org/blog/2018/04/g...
Code for this part can be downloaded here:
github.com/kidscancode/topdow...
Support me on Patreon: / kidscancode

Пікірлер: 162
@michaelthelen5297
@michaelthelen5297 6 жыл бұрын
Man these vids are so good. The pacing is right on point and its great to see a whole project come together and not just a small specific example. Im learning a lot about code layout and architecture within Godot.
@nicklansbury3166
@nicklansbury3166 6 жыл бұрын
Excellent tutorial. The game is taking shape nicely. Thanks Chris.
@Crowbarkz
@Crowbarkz 6 жыл бұрын
Your content for godot is the best on youtube imo, very nice explanation
@Kidscancode
@Kidscancode 6 жыл бұрын
Thanks!
@SergioCandelaRamirez
@SergioCandelaRamirez 4 жыл бұрын
Well, first of all, I can't thank you enough for creating these high-quality tutorials for Godot 3.0...Thank you a million times... 2nd of all, I've strugling with this part 4 for days now, because I didn't manage the bullet to be shooted (Turns out, the Muzzle was too close) and lately I've been struggling with a only one shoot issue (As it turns out, I only had to connect the timeout signal) I'm really happy to announce that I'm going to the next one Thanks Chris!
@AkselNooitgedagt
@AkselNooitgedagt 4 жыл бұрын
I had my Muzzle too close as well. Thank you!
@frankwenner8782
@frankwenner8782 6 жыл бұрын
I love these tutorials. Keep up the good work!
@MattHuisman
@MattHuisman 6 жыл бұрын
Yes!!! I'm always hoping for one of these every time I open my subscriptions!
@channelnumber52
@channelnumber52 5 жыл бұрын
I like this video. This series is great, and I ran into a bug in this stage, that was my own damn fault. And I want to put it here in case it helps anyone else. I was able to shoot my bullets, but they would flash on the screen and then instantly disappear. So I drove around in the game just trying to fire, and then randomly some actually shot and moved like they were supposed to. It took a little thinking, but I finally figured out, I could only fire when my turret was angled one specific way. The reason? I had my muzzle set a little too close to the tank, and the bullets would spawn, and touch the tanks hitbox, which caused their explode method to be instantly called. And that I didn't move the bullet scene to it's own collision layer. If I had fixed either of those problems, I wouldn't have had any issues. But, I managed to get both of those things wrong. Oops.
@duckpond0007
@duckpond0007 5 жыл бұрын
Thanks, I had the same issues
@andrewtabak4893
@andrewtabak4893 5 жыл бұрын
Thank you so much, I had the same problem and I was tearing my hair out because I couldn't figure it out.
@crypsisjim
@crypsisjim 4 жыл бұрын
I'll throw in another thank you here as well. This is how internet communities and open source software get to where they need to be. Thanks for taking the time. On another note, I have been learning the hard way that it pays off in the long run not to rush anything. This bug was caused by me setting the tanks collision in a sloppy rect that was slightly too big. If I had taken the time to set it nicely in the first place I probabaly never would have had this issue.
@Vejitasei
@Vejitasei 4 жыл бұрын
HOLY FRACK!!! TY :) Had the exact same issue and was working on it for the last 20mins+ So much to learn.
@mahtansir8775
@mahtansir8775 6 жыл бұрын
If you guys forgot like me, you can add "shoot" signal in the top of tank script. Thank you KCC.
@j.d.waterhouse4197
@j.d.waterhouse4197 6 жыл бұрын
The '_on_Tank_shoot' function in the Maps node is an excellent and easy place to add a particle node 'Smoke' to produce smoke coming out of the turret when you shoot - (for all of you trying to keep up with Chris' tutorials). The function already has location and direction. But Chris may have been planning to add this in the next video.
@Kidscancode
@Kidscancode 6 жыл бұрын
Maybe not in the next video, but visual effects like muzzle flash, smoke, tank tracks, etc are on the list. ;) These kinds of effects really add a lot to the game.
@j.d.waterhouse4197
@j.d.waterhouse4197 6 жыл бұрын
Yep, it might not be a good idea for anyone to start adding things now which might conflict with what you'll be adding later on.
@mimique_key
@mimique_key 5 жыл бұрын
Would setting the offset of the bullet sprite with "flip h" also work to rotate it ? Also I have a problem to connect the "on_GunTimer_timeout" signal to the tank.gd script. Actually none of the nodes in the Tank.tscn scene have the option "Make Function" when I try to connect a signal. But in my other scene of the project i don't have this issue. EDIT: My bad, I found the problem. For some reason my Tank.gd script wasn't attach to my Tank node.
@giggleghost3751
@giggleghost3751 4 жыл бұрын
There were some things that I either slept through or we didn't do them. But it just made me feel good for debugging them myself. - Declare 'shoot' signal in Tank script. - I had to hook up bullet timeout() to bullet script, for some reason I didn't have that part. - Player bullet needs collision shape chosen, I forgot to give it a shape. - Player bullet needs collision layers set up so that it collides only with environment and enemies, but not the player itself.
@WoYoSenseiPL
@WoYoSenseiPL 5 жыл бұрын
No offence, but I'll leave my final comment for the last video. I love the series so far and I love your different and very original approach to do things. It's just if I want to leave a comment about how great this series is I will have to do it every time after every video :P These moments when you leave us without explanation is kind of good (I was back to the series after a while and had to watch it again because I forgot things :) ). Me like it! :) I can't wait how this series will end! Very interesting! PS. I was looking for a way to convert my game from GameMaker Studio 2 to Godot (which is top-down zombie arena shooter). Now I know! Cheers!
@carlosaires2688
@carlosaires2688 4 жыл бұрын
Excellent tutorials. Thanks for Brazil
@mitchmaynard7311
@mitchmaynard7311 Жыл бұрын
Great tutorial! I was having issues in Godot v3.5 getting the bullet to disappear after the Lifetime timeout occurs. The solution for me was to turn on Autostart on the Lifetime timer.
@Peter-wl5xm
@Peter-wl5xm 3 жыл бұрын
Hello everyone, I understand that the AI Tank needs rotation to follow the Player, but doesn't our lookat() function already rotate the turret and muzzle? Can someone explain why we need to pass a rotation into our bullets start() function? And also in our shoot() function, is the unit vector Vector2(1,0) just an arbitrary direction we use for rotation? Or is there a reason that it is specifically in that direction. Thank you for anyone that gives me insight!
@thientrinhinh6956
@thientrinhinh6956 2 жыл бұрын
If you have the issue like me: the bullet just flash once, then never appear again, you may want to check: 1. like channelnumber52 had said: in PlayerBullet scene, move the collision layer to 'player', the mask to 'environment' and 'enemies'. 2. I don't know if I miss something, but in function shoot(), the variable 'can_shoot' is toggle to false and never turn true back, so I can not shoot again. You will want to connect the signal 'time_out' of GunTimer to Tank scene, then set can_shoot = true when this signal emit. You can shoot again now. Hope this will help someone.
@alm5966
@alm5966 9 ай бұрын
One little addition which will return the enemy turret back to facing the direction of the tank body after the player has left the detection zone:- Add a class level variable:- Var turret_rotated : bool = false Add turret_rotated = true to the If statment in _process Add turret_rotated = false to the OnBodyExit callback Add a new If statement to the _process if !target and turret_rotated == false: $turret.rotation = lerp_angle($turret.rotation, $tank_body.rotation, rotation_speed * delta) Once the player exits the detection zone, the enemy turret will rotate back to facing the tank body direction.
@mitchellstephens4228
@mitchellstephens4228 4 жыл бұрын
can anyone give a quick description of the most proper way to add a second enemy tank? do you duplicate, or just add a new node? when i tried duplicating, if i edited one Path2D, it edited both. When i made a new node line, I wasnt able to distinguish different detect radius sizes. I tried setting one to 100 and one to 500, but both came out as 500. Any ideas?
@MsKocagoz
@MsKocagoz 6 жыл бұрын
Can you suggest me a tutorial, I want to click tank and move to another point which is clicked with mouse. Like strategy game style. Many Thanks
@Kidscancode
@Kidscancode 6 жыл бұрын
This tutorial has a nice overview of 2D movement, including click-to-move: docs.godotengine.org/en/latest/tutorials/2d/2d_movement.html
@JulianGuerra84
@JulianGuerra84 6 жыл бұрын
I love the tutorial. I have a question. Is it possible that I have to call $Lifetime.start() after $Lifetime.wait_time = lifetime? Because apparently it takes the default value of 1 second from the timer, and by the time I assign the new lifetime the timer is already running.
@eduardjsx
@eduardjsx 4 жыл бұрын
You need to run $Lifetime.start() after setting the new wait time on start :) Author missed a few things in the tut.
@bludabi6135
@bludabi6135 4 жыл бұрын
I can shoot perfectly fine, and the bullet moves in the correct direction, only issue is, the bullet doesn't rotate, so it looks very strange. Any idea what I did wrong?
@j.d.waterhouse4197
@j.d.waterhouse4197 6 жыл бұрын
Oops kids, Chris is brilliant...but there is no 'shoot' signal in Tank.gd in the first video, and he added it later while we weren't looking. I'm positive he just did this to check to see if we were paying attention lol. Great video otherwise.
@Kidscancode
@Kidscancode 6 жыл бұрын
I'll take that! Yes, I was testing you... In reality, I may have just missed an edit when I was putting the video together.
@panther7584
@panther7584 3 жыл бұрын
Everything works out but the bullet does not travel any further, just spawns on my turret's 2d muzzle position then despawns. How can I make it travel?
@153sqrd4
@153sqrd4 5 жыл бұрын
So I'm pretty sure this video left out adding the shoot signal, and setting can_shoot back to true. Also, if anybody notices that the enemy tank no longer detects the player, check the layering section under the player. It took me hours to figure it out, as I thought I had messed up something while trying to fix the shooting issue. Turns out I had forgotten all about the layers.
@hewe8005
@hewe8005 5 жыл бұрын
The 2 hints should be marked out better. The point with the position of the muzzle like channelnumber52 mentioned and the issue with the start time in the parent scene/class of the playerbullet. Anyway still a great tutorial. Keep going like that! Cheers! :)
@pomegranate8593
@pomegranate8593 10 ай бұрын
for others in godot 3.5: toggle on autostart and one shot on in the inspector for timer, they are off by default and mess things up
@folks1778
@folks1778 6 жыл бұрын
I keep getting "Invalid call. Nonexistent function 'instance' in base Nil", when trying to instance the bullet on the map, any ideas?
@Kidscancode
@Kidscancode 6 жыл бұрын
You haven't assigned anything to the Bullet property. Click on the Player (or Enemy) and drag the bullet into the property in the Inspector.
@EightNineOne
@EightNineOne 6 жыл бұрын
Thank you so much! I've bee struggling with projectile positioning, Godot docs need so much work
@Kidscancode
@Kidscancode 6 жыл бұрын
I'm curious why you say that. Over the past few months there has been a huge improvement to the official docs - enough that I can typically just link people when they have questions. It would be helpful to know where you think there are holes or missing content.
@EightNineOne
@EightNineOne 6 жыл бұрын
They’re still a bit idiosyncratic for a new user I suppose. I’m fairly new to Godot and so far it’s been half “that just worked first time, I think I’m falling for GDscript” and half googling some really basic questions. Overall, I’m enjoying it. I think I’ll get suggestions on the docs repo going forward.
@Kidscancode
@Kidscancode 6 жыл бұрын
Please do. As a community project, that's the best way we find out what needs doing!
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
Did you give names to the layers in the third part of the textbook or in the fourth?
@Kidscancode
@Kidscancode 6 жыл бұрын
Textbook? kidscancode.org/blog/2018/04/godot3_tanks_part4/
@diegomata1062
@diegomata1062 2 жыл бұрын
hello, why does _on_Tank_shoot has 3 parameters?
@brendanyoon5745
@brendanyoon5745 Ай бұрын
Everything works great except my bullet doesnt move when its instanced. Any thoughts on why this would happen? I can post code if needed. Thanks!
@maktrone-learning611
@maktrone-learning611 4 жыл бұрын
Very good
@Bianchi77
@Bianchi77 4 жыл бұрын
from debug I got : E 0:00:04:0818 Error calling method from signal 'shoot': 'KinematicBody2D(Player.gd)::_on_Tank_shoot': Method not found. core/object.cpp:1238 @ emit_signal() Tank.gd:28 @ shoot() Player.gd:18 @ control() Tank.gd:33 @ _physics_process() I have added the function at Tank.gd , what do I miss here ?
@MiguelGarcia-ku3yh
@MiguelGarcia-ku3yh 6 жыл бұрын
Hey, Chris! Thanks for these great tutorials. Sorry for bothering you, but I am really missing a point here: When I try to add the 'timeout()' signal to the GunTimer timer in the tank.gd script, it says "Target method not found!". I don't get it, since it's already there (i've created the _on_GunTimer_timeout() function) and i've seen in your code it's there too, with the signal added in the inspector. More about it: If I disconnect the signal in your project, I won't be able to connect it again with the same procedure. I get the signal basics, but I don't really get why I can't connect this one and it's being really frustrating. I already revised the code twice and I don't get why. Thanks so much
@Kidscancode
@Kidscancode 6 жыл бұрын
Are you mixing up the Tank scene and EnemyTank scene? The EnemyTank's script doesn't have that function, so you would get that error. The signal connection should happen in the timer on the base Tank scene.
@MiguelGarcia-ku3yh
@MiguelGarcia-ku3yh 6 жыл бұрын
Chris, sorry for bothering you. I didn't mix the scripts/nodes, I was trying to add the timeout() signal to the GunTimer time node itself, insted of - obviously - to the main node there, which is the main KinematicBody2D one. Long road ahead, but being way easier with your videos. Thanks!
@gerbolesinc.3432
@gerbolesinc.3432 5 жыл бұрын
Hello Miguel, I went through the same issue, you may not have the Tank.gd script assigned to the Tank node. It was difficult to see in the video and in the written version. Hope I was helpful. Regards.
@lkasikakalus123
@lkasikakalus123 4 жыл бұрын
for some reason lifetime did't work. i need to change player_bullet timer_node.wait_time menualy. can i know the reason?
@mahtansir8775
@mahtansir8775 6 жыл бұрын
[Solved]My bullets are disappearing after a few pixels in specific areas of the terrain... Any idea why is it being?
@mahtansir8775
@mahtansir8775 6 жыл бұрын
Solved, if someone lives that situation just go to the "PlayerBullet" and select layer as only "bullets", and make the masks as "environment, enemies and bullets", it's done!
@floriansperber1667
@floriansperber1667 5 жыл бұрын
This was driving me crazy, thank you!
@Nobody-fm6ch
@Nobody-fm6ch 4 жыл бұрын
U r awesome, dude
@leviathan-supersystem
@leviathan-supersystem 4 жыл бұрын
@@mahtansir8775 my man 😎
@duyenbui2001
@duyenbui2001 4 жыл бұрын
man i got eveything you have but my tank only shoot 1 and not another
@ElShowDeJohnnyKraft
@ElShowDeJohnnyKraft 5 жыл бұрын
Saw this tutorial a couple times and i cant figure where you defined the _direction that is given passed to the bullet (i just saw "dir"). It keeps throwing me that issue when trying to run.
@Kidscancode
@Kidscancode 5 жыл бұрын
If you mean the "start" function, we need to pass it a position vector and a direction vector: func start(_position, _direction): In the tank's "shoot" function we calculate the desired direction (called it "dir") and pass that along with the rest of the data when we emit the "shoot" signal.
@ElShowDeJohnnyKraft
@ElShowDeJohnnyKraft 5 жыл бұрын
@@Kidscancode doesn't that caused you any issue? I mean, you called it dir in one place but when moving it to another, it is suddenly named _direction. In my case, it threw me a parse error cause it couldn't identify the latter.
@Kidscancode
@Kidscancode 5 жыл бұрын
A function's parameters can have any name - they only exist inside the function. And you can pass any value to the function. "dir" is just a temporary variable in one spot to hold the calculated angle value so we can pass it. We could have written the angle calculation directly in the function call, but that would just result in a long and difficult to read line.
@ninjacookbilly3474
@ninjacookbilly3474 4 жыл бұрын
My bullet only fires once and then doesn't destroy itself. I have everything the same as the tutorial I triple checked. I am not getting an error and I adjusted the speed of the bullet to 1 to see if it destroyed itself but it doesn't. If I adjust Lifetime in PlayerBullet that number doesn't do anything.
@Kidscancode
@Kidscancode 4 жыл бұрын
Download the project from the link in the description. See what you missed.
@ninjacookbilly3474
@ninjacookbilly3474 4 жыл бұрын
@@Kidscancode Okay now I see that the _on_GunTimer_timeout(): can_shoot = true but I didn't see you do that in any of the videos. I have tried to set this up by myself by selecting the GunTimer then going to node and selecting timeout() but it gives me an error "Target method not found! Specify a valid method or attach a script to target Node." I am lost now why it isn't working or what I am doing wrong. I tried to coding that line it but it changed nothing also.
@Flomista9722
@Flomista9722 5 жыл бұрын
Hello my tank only fire once: gun cooldown is set ,timeout on GunTimer is connected (tank.gd) Edit :I finally found the problem i have put the signal connexion on the wrong place (player.gd) with a "pass"
@chance_E
@chance_E 5 жыл бұрын
could you tell me what you did?
@thezyreick4289
@thezyreick4289 5 жыл бұрын
Hello, I have been watching your tutorials for learning Godot coding since I started in game development, and I have taken the information learned in several tutorials and done my best to implement it into my own game. I am having an error however. when I go to shoot the bullet, it has an issue with timing out and collisions, the bullet either flies forever or despawns immediately, and it does not collide with anything I am in Godot version 3.1 here is my base script: extends RigidBody2D signal shoot_bullet signal dead signal health_changed export (PackedScene) var Bullet export (int) var engine_thrust = 500 export (int) var spin_thrust = 2000 export (int) var health = 100 export (float) var bullet_cooldown = 1 var alive = true var can_shoot_bullet = true var thrust = Vector2(0,0) var rotation_direction = 0 func _ready(): $BulletTimer.wait_time = bullet_cooldown func get_input(): pass func shoot_bullet(): if can_shoot_bullet: can_shoot_bullet = false $BulletTimer.start() var dir = Vector2(1,0).rotated($Turret.global_rotation) emit_signal('shoot_bullet', Bullet, $Turret/Muzzle.global_position, dir) func _physics_process(delta): if not alive: return get_input() set_applied_force(thrust.rotated(rotation)) set_applied_torque(rotation_direction * spin_thrust) func _on_BulletTimer_timeout(): can_shoot_bullet = true
@thezyreick4289
@thezyreick4289 5 жыл бұрын
here is my player script: extends "res://Scripts/ship_script.gd" var screensize func _ready(): screensize = get_viewport().get_visible_rect().size func get_input(): if Input.is_action_pressed("ui_up"): thrust = Vector2(engine_thrust, 0) else: thrust = Vector2() rotation_direction = 0 if Input.is_action_pressed("ui_left"): rotation_direction -= 1 if Input.is_action_pressed("ui_right"): rotation_direction += 1 if Input.is_action_pressed("shoot_bullet"): shoot_bullet() func _process(delta): get_input() ---------------------------------------- and here is the world script: extends Node2D func _ready(): pass # Replace with function body. func _on_Ship_shoot(bullet, _position, _direction): var b = bullet.instance() add_child(b) b.start(_position,_direction)
@Bianchi77
@Bianchi77 4 жыл бұрын
I can not see bullet yet when I clicked the mouse ? Is it not visible ? How can I fix it ? thanks
@schnitzelhannes6431
@schnitzelhannes6431 4 жыл бұрын
lol
@russellchao2089
@russellchao2089 5 жыл бұрын
I just ran into a new problem when I’m shooting bullets. At times when I’m shooting, my bullets will sometimes dissappear after a split second instead of lasting a 0.5 lifetime after I fire bullets. Why is that?
@Kidscancode
@Kidscancode 5 жыл бұрын
Probably this is because the bullet is detecting the tank that's shooting it. Check that your collision layers are set correctly on the tanks and bullets.
@russellchao2089
@russellchao2089 5 жыл бұрын
Well it looked like it was a problem with the layers and I just adjusted some of them and got my shooting to work normally again. Thanks for your help!
@nelsonsmg77
@nelsonsmg77 4 жыл бұрын
This doesnt have anything to do with the video but does anyone, when running the player tank scene alone, collide with invisible walls?
@schnitzelhannes6431
@schnitzelhannes6431 4 жыл бұрын
lol
@russellchao2089
@russellchao2089 6 жыл бұрын
I have 2 problems:1. Whenever I shoot a bullet, the bullet will keep moving instead of dissapearing after a 0.5 lifetime.2. When I start the game, I am only able to fire once after clicking on the mouse and I can’t fire anymore for the rest of the game.
@Kidscancode
@Kidscancode 6 жыл бұрын
Those are both signal problems. When the bullet's "Lifetime" Timer sends out its "timeout" signal, that's what frees the bullet. And the GunTimer's "timeout" signal is what sets "can_shoot" back to true. Click on each Timer node and make sure you have the "timeout" signal connected correctly.
@MattRose30000
@MattRose30000 6 жыл бұрын
My bullets only will disappear properly if I set the Wait Time on the Lifetime node of the Bullet scene. Setting this in the Script Variables does nothing. Any idea what I did wrong?
@Kidscancode
@Kidscancode 6 жыл бұрын
Possibly you're not using the script variable to set the wait_time? $Lifetime.wait_time = lifetime
@MattRose30000
@MattRose30000 6 жыл бұрын
I did use that. I downloaded your example code for this episode and there the Wait Time in the Timer node was set to .5 When I set that to 1, it stays one in the game, although the export vars in the PlayerBullet is still set to five. I think this makes sense since the Timer is a child of the Bullet node and everything that is set on the child overwrites its parent. But then again, changing the wait_time of $Lifetime should overwrite this, which it doesn't (I tried it with your sample code)... I am mildly confused why this works in your video.
@Kidscancode
@Kidscancode 6 жыл бұрын
Wow, you found a bug! Somewhere along the way of editing and recording, I lost "$Lifetime.start()" , which must be called after you set the wait_time. This is the problem with recording things and not going back and checking. Sorry about that! I'm also wondering now if we even need the lifetime variable, when we could just set it directly in the Timer node. I think it's more explicit this way, but it adds code that's not really necessary. I will probably change it in the next part.
@sneezyboye7685
@sneezyboye7685 3 жыл бұрын
My bullet generates, but nothing else works. You can't see it and it doesn't go through the _process function. Any ideas?
@sneezyboye7685
@sneezyboye7685 3 жыл бұрын
NEVERMIND I'M AN ABSOLUTE BRAINLET AND DIDN'T ADD "ADD_CHILD(B)"
@hamzaplaysgt7467
@hamzaplaysgt7467 4 жыл бұрын
error(18,10): The method "shoot" isn't declared in the current class. does anyone know how to fix this issue btw its in the Player.gd script
@Kidscancode
@Kidscancode 4 жыл бұрын
You haven't declared "shoot". Look for a misspelling and compare the code with the tutorial again.
@xkenoma
@xkenoma 6 жыл бұрын
Excellent and insightful tutorial sir. :) However, whenever I run my map scene and click LMB to shoot, the game crashes and gives me this error at line maps/Map.gd:15 on the part where var b = bullet.instance()
@Kidscancode
@Kidscancode 6 жыл бұрын
You didn't include the error. Is it a "null instance" error? If so, it's because you didn't add the bullet scene to the exported "bullet" property. If not, you'll have to show the error...
@xkenoma
@xkenoma 6 жыл бұрын
KidsCanCode I decided to just redo from part 1 and followed everything from your tutorial up to this part. Everything seems to be working fine now. However, the only issue is that the bullet keeps existing whenever I shoot. I edited the zoom from the camera and the bullet actually doesn't die and keeps going forever. I figured it's the queue_free() thing but it's the same as you did.
@Kidscancode
@Kidscancode 6 жыл бұрын
The bullet is deleted by the Lifetime timer reaching its end and then the explosion playing. Did you connect the "timeout" signal of the Timer?
@xkenoma
@xkenoma 6 жыл бұрын
Everything works fine now. I finished following the rest of your tutorial until part 9 and the rest is smooth and clear. About that shoot bullet, I managed to fixed it by just exploring the editor itself. I think there are two possible sources that I remember about the issue that I mentioned before. First is that you moved the Muzzle's Position of the Player from 55 to 65 on the X axis, and you didn't directly show it or mentioned it (I think). I figured the bullet detects the Player's own collision shape and explodes. Second is the Collision Layer (or Mask) of the PlayerBullet itself. I don't also remember (also I'm not sure) you doing it on this part. Anyways, the issue is not of a big deal, and in fact increadibly beneficial for me as the rest of the issues that I've encountered either revolved on leaving the script variables blank, the collision layers and masks and stuff like those. Overall, your tutorial is very insightful and really helpful for me. :) Btw, how can I contact you aside from here? I'm currently into a Godot Facebook group and posting stuff, but I think asking you myself will be most helpful. I'm currently continuing your game from this series and currently on the part of making a Boss Tank with two independent turrets. :33
@mushr00msamba83
@mushr00msamba83 5 жыл бұрын
for the bullet not disappearing, try setting the Wait time on the PlayerBullet Timer to 0.5. That worked for me
@thomashalsted1888
@thomashalsted1888 5 жыл бұрын
Hey, any idea why the screen goes black from 16:08 to 16:09?
@Kidscancode
@Kidscancode 5 жыл бұрын
Nope. I wonder if that's in the original recording or crept in when encoding/uploading.
@stephendyson3003
@stephendyson3003 2 жыл бұрын
detect_radius isnt unique to each instance when setting different values in the inspector, all sharing the same value
@Kidscancode
@Kidscancode 2 жыл бұрын
Yes, that's how shared resources work. Make your collision shapes unique if you don't want them to be shared.
@py-lord
@py-lord Ай бұрын
And there are videos in which the same code is converted to Godot code 4.2?
@diegomata1062
@diegomata1062 Күн бұрын
nope but you can watch other videos about the same subject and change things accordingly thats what im doing
@py-lord
@py-lord Күн бұрын
@@diegomata1062 can you please help me find these videos?
@diegomata1062
@diegomata1062 Күн бұрын
@@py-lord sure, Cashew OldDew, branno those are the ones that are really good, they make different games but solutions to problems are there also search for the specefic issue you have on youtube be specific by searching godot 4
@GregSole
@GregSole 5 жыл бұрын
Love the series, but I have hit a problem. As soon as I click to fire I get an error "Invalid set index 'wait_time' (on base: 'null instance') with value of type 'float'." Related to line 12 of Bullet.gd ($Lifetime.wait_time = lifetime)
@Kidscancode
@Kidscancode 5 жыл бұрын
It seems like "Lifetime" isn't what you named the timer node.
@GregSole
@GregSole 5 жыл бұрын
@@Kidscancode Oh wow, you're right. I called it LifeTime. I really wish I could tell what errors meant. How long do you need to be coding to get as comfortable with it as you are?
@Kidscancode
@Kidscancode 5 жыл бұрын
I can't really answer that question. It's mostly a matter of experience. Since I teach beginners a lot, I can pretty quickly spot the common mistakes that happen often.
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
I did as you showed, but my tank shoots once and does not fire anymore.
@Kidscancode
@Kidscancode 6 жыл бұрын
Then you likely forgot to connect the "GunTimer" timeout signal.
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
Thank you
@gsvjv
@gsvjv 5 жыл бұрын
ummm Chris there is no script attached to the base Tank Scene and the func _onGunTimer_timeout(): in both inherited scripts (Player and EnemyTank) simply has pass? Obviously we need to set can_shoot to true but... regardless... when did we do this? Also if Input.is_action_just_pressed('click'): shoot() Where did we set 'click'? in the first tutorial it was 'shoot' Incredible stuff though... as always
@Glankonian
@Glankonian 6 жыл бұрын
[Solved]Since I figured out how to tell the right Bullet was being passed to the Map, I added some print statements to the Bullet.gd to see what was happening there. Bullets are being generated. However, they are not timing out, not colliding with anything and not explode()ing. Also still not visible... [Note] I sent this message then coulden't find it and re-did it. In the revised edition, I had found I had missed the + in position += velocity * delta. Bullets now flew and hit Enemy tanks, but did not time out. [Fixing Edit] Found I forgot to enable OneShot and AutoStart on the Bullet timer. Thanks for the help and hope this helps someone else.
@Glankonian
@Glankonian 6 жыл бұрын
DOH! Missed += in position += velocity * delta for Bullet process. So Now I see Bullets and the move across the screen. They also explode(): when hitting an enemy tank. However, they don't time-out and continue on forever...
@Kidscancode
@Kidscancode 6 жыл бұрын
The timing out is handled by the "Lifetime" Timer node. The "timeout" signal should be connected to a function that calls "explode".
@ianmclennan2090
@ianmclennan2090 4 жыл бұрын
You saved me
@Glankonian
@Glankonian 6 жыл бұрын
Ok, I need some debugging help. Please, I see no bullets when I shoot. My attempts to debug my code show that the 'can_shoot' variable gets set to false the first time, but never reset. I don't see the Gun_timmer counting down, so it never resets 'can_shoot'. But, that doesn't answer why I never see the initial bullet either... I've downloaded your code and poured over both versions and still can't see where mine went wrong. I want to truly understand how to locate and fix such bugs before continuing, as it is an important skill to have.
@Kidscancode
@Kidscancode 6 жыл бұрын
Check that your player's shoot signal is connected to the main scene's "_on_Tank_shoot()` function.
@Glankonian
@Glankonian 6 жыл бұрын
It appears to be. The Print I placed in there attempting to verify the proper bullet image shows up in the output the first time I shoot.
@mahtansir8775
@mahtansir8775 6 жыл бұрын
Mine is shooting in the first click but not doing it again. Map01 scene's player's shoot signal seems connected to "_on_Tank_shoot()" func. Did you solve it Glankonian?
@mahtansir8775
@mahtansir8775 6 жыл бұрын
Ok i got it now, in tank scene, add timeout signal to "GunTimer" and make can_shoot = true so; "func _on_GunTimer_timeout(): can_shoot = true" this should be in tank.gd
@Glankonian
@Glankonian 6 жыл бұрын
Thanks Mahtan, Seems I did miss the GunTimer signal. My print statements indicate _on_GunTimer_timeout(): is now being called at regular intervals. Still no image of bullet on screen. :(
@koemdjiev
@koemdjiev 5 жыл бұрын
what is a "Unit Vector"?
@Kidscancode
@Kidscancode 5 жыл бұрын
Vector math is used extensively in game development. If you're not familiar with it, here's a good primer: docs.godotengine.org/en/3.0/tutorials/math/vector_math.html#unit-vectors
@elidelid
@elidelid 5 жыл бұрын
I can't shoot the bullet :(
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
how did you make the two tanks? you copied and pasted it?
@Kidscancode
@Kidscancode 6 жыл бұрын
Do you mean the two enemy tanks? They are each instances, added to the scene using the "Instance" button.
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
where is this button located?
@Kidscancode
@Kidscancode 6 жыл бұрын
The "instance" button is located right next to the "Add node" button. This is all covered in the beginner tutorials I referred you to. This series is not going to cover these kinds of things.
@askaranarbekov3145
@askaranarbekov3145 6 жыл бұрын
I did as you showed, but my tank shoots once and does not fire anymore.
@TheSdoWn
@TheSdoWn 6 жыл бұрын
Hello. I get this error(It doesn't crash the game) 0:00:01:0956 - Error calling method from signal 'shoot': 'KinematicBody2D(Player.gd)::_on_Tank_shoot': Method expected 0 arguments, but called with 3. ---------- Type:Error Description: Time: 0:00:01:0956 C Error: Error calling method from signal 'shoot': 'KinematicBody2D(Player.gd)::_on_Tank_shoot': Method expected 0 arguments, but called with 3. C Source: core\object.cpp:1202 C Function: Object::emit_signal This should be pretty clear but I'm not so sure where is the error
@Kidscancode
@Kidscancode 6 жыл бұрын
There's something wrong with your signal connection. When we emit the signal, we send 3 parameters along, but the method you connected has no arguments defined.
@chance_E
@chance_E 5 жыл бұрын
why does my bullet only fire once
@Kidscancode
@Kidscancode 5 жыл бұрын
Did you connect the "timeout" signal of the gun timer?
@magicalcrystal7352
@magicalcrystal7352 3 жыл бұрын
kids can't code this
@pomegranate8593
@pomegranate8593 10 ай бұрын
ARIGATO
@chance_E
@chance_E 5 жыл бұрын
my bullet never despawns
@Kidscancode
@Kidscancode 5 жыл бұрын
Did you connect the "screen_exited" signal of the VisibilityNotifier2D?
@wut13
@wut13 5 жыл бұрын
@@Kidscancode where in the video did you add the VisibillityNotifier2D?
@Kidscancode
@Kidscancode 5 жыл бұрын
@@wut13 We don't use a notifier. Since the bullets have a lifetime, that despawns them. My comment above was in error.
@nsmbfan
@nsmbfan 5 жыл бұрын
How can I control the bullet direction without using a mouse as a reference point? I just want my space ship to shoot in any direction it's looking. Please help me kind sir. Here's my project on git: github.com/CreaseLearnsGodot/SpaceGame
@Kidscancode
@Kidscancode 5 жыл бұрын
In this project, the bullets always shoot in the direction the turret is facing. For the player, that's controlled by the mouse, but for the enemy tanks it's not. Have a look at the "shoot()" function in Tank.gd. Use your spaceship's rotation to set the bullet's direction in the same way.
@nsmbfan
@nsmbfan 5 жыл бұрын
@@Kidscancode Thanks for the fast reply! I'm still hard at work. Took a break to do some graphics. Gonna go check out the Tank.gd now. I think it may have to do with the fact I'm using a rigid body bullet.
@nsmbfan
@nsmbfan 5 жыл бұрын
@@Kidscancode Ok so as logical as that seems, my syntax must not be up to par with .gd yet. Your enemy tank just locks on, calls target, and fires away and maybe misses 1/10 times. Does that store the direction/global.position in the variable? Should i still be using my if on_action to start my shoot statement since player doesn't have detectradius ? i like the .9, but i played yours and it was like the enemy was aimbotting. good golly i have a ways to go. but this is addicting, i have to figure this out.
@nsmbfan
@nsmbfan 5 жыл бұрын
@@Kidscancode Man I got this dude thank you. It takes hearing it like 10 times for me. I just had to REALLY watch why you were doing it the way you did. That's why this really interests me. It's been YEARS since I've coded. People now have it too good. Godot is amazing!
@Huderlord
@Huderlord 6 жыл бұрын
Your tuts are awesome. I learned how to use path nodes. I tried to do things a little complicated so i added collisions with roads. Player and enemies speed is increased on roads. And also i got improved path AIs. My AI can tell if got stopped by something and then tries to go in reverse direction to unstuck. My video that shows this kzbin.info/www/bejne/pJiZioKph5eqpqM
@Kidscancode
@Kidscancode 6 жыл бұрын
That's great! You're getting ahead of me.. :)
Godot 3.0: Top-down Tank Battle - Part 5
13:43
KidsCanCode
Рет қаралды 17 М.
Godot 3.0: Top-down Tank Battle - Part 1
19:36
KidsCanCode
Рет қаралды 104 М.
Despicable Me Fart Blaster
00:51
_vector_
Рет қаралды 22 МЛН
Зачем он туда залез?
00:25
Vlad Samokatchik
Рет қаралды 3 МЛН
One moment can change your life ✨🔄
00:32
A4
Рет қаралды 31 МЛН
Tierlisting the BEST (and worst) GAME ENGINES
33:51
BiteMe Games
Рет қаралды 206 М.
Godot 3.0: 2D Visibility with Ray-casting
22:22
KidsCanCode
Рет қаралды 70 М.
The Best FREE Software for Game Development! (In my Opinion)
11:06
choosing a game engine is easy, actually
15:08
samyam
Рет қаралды 351 М.
I Melted Wood With Friction
8:44
The Action Lab
Рет қаралды 715 М.
4 Godot 4 Devs Make 4 Games in 44 Hours
25:19
DevLogLogan
Рет қаралды 493 М.
Design and Code a Title Screen in Godot 3 (tutorial)
32:42
GDQuest
Рет қаралды 149 М.
Godot 3: Finite State Machine Code Example Overview
11:41
GDQuest
Рет қаралды 86 М.
Godot 3.0: Top-down Tank Battle - Part 10: Homing Missiles
15:21
KidsCanCode
Рет қаралды 10 М.