You are like a hero, the hero of Godot and all you teach is a gift for us. Thank you a lot!!
@josesena43146 жыл бұрын
This is one of the most useful Godot tutorials I've ever seen. Great to se somebody making really original and useful videos. Thank you a lot for this!
@Kidscancode6 жыл бұрын
Thanks!
@daviddalisay53175 жыл бұрын
I love that you did the break at 20:10. I appreciate your video's focus on code quality/efficiency while making an enjoyable game.
@benrainero97964 жыл бұрын
great tutorial. something to mention is that if the player rotates, their collision shape will rotate as well and you'll need to rotate the corner points around the player position before doing the vector math to get their position in game space
@snstarosciak4 жыл бұрын
I just started getting back into Godot after over a year and been using Godot 3.1 (and now Godot 3.2) and I just went through this video and the best part is after I first investigated the starter code, I actually learned how to do projectiles from turrets (which is something I didn't know how to do) and now understanding how to do this Raycasting stuff is extremely powerful. I've seen it used for tons of other reasons but never fully got how it worked. Thanks again! I love your teaching style which makes it fun to learn about this :D If you were able to do more series on, say a combat system which could utilize this and stuff in some of your other videos, that would be so awesome :) I know combat is a pretty heavily used mechanic in a number of games and seeing how you would set it up and do it would be beneficial for everyone. Cheers!
@idleman54632 жыл бұрын
The tutorial is still very helpful after all the years, thank you.
@noc2_art5 жыл бұрын
What a master! And you devise such effective and scalable solutions. Thank you so much for sharing your knowledge with us.
@rafaelgpontes6 жыл бұрын
Man, your tutorials are great! Be sure of one thing: you are changing lives, man!!! Keep up the great work. Cheers from Brazil. :)
@MisterBrown946 жыл бұрын
Every video is soooo useful. No matter what you cover, I always learn something I didn't know. Thank you a lot!
@indigoblacksteel11766 жыл бұрын
You mentioned at the end of this video that a person could do reflections by starting a raycast where the other left off. And then that you could put that into a loop to have it bounce multiple times. I'd love to see one where you showed the code of how to do that efficiently.
@tomanski37674 жыл бұрын
Thank you so much! Probably the best godot tutorials I have ever seen!
@androskris6 жыл бұрын
Nice, wish I had tutorials like this when I was 15 and trying to code games on my C64 with Gary Kitchen's Gamemaker
@MsKocagoz6 жыл бұрын
One more great tutorial, with your help I will open my own game studio :)
@Kidscancode6 жыл бұрын
Good luck!
@wearegeek6 жыл бұрын
Awesome! One can never have enough Godot tutorials. ^_^
@fossegutten65796 жыл бұрын
Very nice video, I prefer these short tutorials over the long series! How did you add custom names to the layers and masks by the way?
@Kidscancode6 жыл бұрын
In Project Settings -> Layer Names -> 2d Physics
@noiJadisCailleach5 жыл бұрын
Added another tool in my arsenal as a game dev. Thanks for this!
@markanthonydelossantos61475 жыл бұрын
great tutorial with clear explation of every code
@thomashalsted18886 жыл бұрын
I needed this video a lot! I'm making a player-controlled turret that fires LASERS. It's fun.
@seishumorales97585 жыл бұрын
Hi, thanks for the tutorial super helpful. One problem with my project is the turret doesn't shoot the player when its radius is touching the platform/walls even when the player is in the radius circle. The walls does have a collision2D shape but looking at your project, i am not sure how you made yours work when the circle is touching the walls.
@MINDoSOFT2 жыл бұрын
Excellent tutorial and lesson !!!
@elerosvecchio4 жыл бұрын
Great tutorial! Do you know how you would get the corners of a 3D object?
@Kidscancode4 жыл бұрын
Depends on the collision shape. If you're using a box shape, you can get the extents in the same way as the rectangle.
@gustavofreitas37343 жыл бұрын
I may be commenting a little bit too late here, but does the turret need to be a kinematic body, or could it be static?
@bubblemage2 жыл бұрын
Hello! I wonder if you'd know some tips to give the player a limited vision range, like the player not being able to see through wall tiles and instead just see darkness. I've already tried to achieve this by using Light2D and LightOccluder2D but this doesn't work as I want it to, I guess I don't want a "flashlight" effect, but more like a true ranged vision. The game "twc byond" achieves this, and I'd like to know how to recreate something like that!
@IustinNitza4 жыл бұрын
I'm getting this error 50% of the time - Invalid get index 'shape' (on base: 'null instance'). How could I make sure that get_node('CollisionShape2D') exists before declaring target_extents var ? If I add an if target.get_node('CollisionShape2D') != null I get some weird behaviour. Thx
@mohdseraj10476 жыл бұрын
Cool tutorial, thanks for that! I've a question, how is it possible to make the enemy shoots at you when he only sees you.
@gameplayandreview5 жыл бұрын
Can you edit it for 3D Environment with a "Cone" Visibility for Enemy (Shape Orientation : point towards enemy and Circle outwards) and "Cylindrical" Visibility for Turret (Shape Orientation : Flat Top & Bottom)? Also can you do an A.I. Pathfinding script.
@RexN66 жыл бұрын
Hey! I was looking for something like this!! Thank you very much!
@Kidscancode6 жыл бұрын
Glad it could help!
@FameMonsterD36 жыл бұрын
Can you do this but instead of shooting, have the turrets chase you and melee. I would like to learn how to do that. Great video man as always.
@Kidscancode6 жыл бұрын
Sure. In my example, I'm using the direction of the raycast to set the direction of the bullets. You could just as well use that direction vector to set your mob's velocity.
@Demogooo4 жыл бұрын
I have a question. You used your current bit mask layers that you had to know when to stop the ray cast, but I have added another layer and mask layer to my enemy, but the problem is that now if I have multiple enemies chasing me, if one enemy that is tracking my player goes behind another, the line of sight will stop and the enemy in front. How could I specify which mask bits I wanted to detect instead of using all the current mask bits I have selected for my enemy? (In this case I just want the first bit mask and if possible, the second as well)
@AgriasOaks994 жыл бұрын
Sir, can we use raycast to show area of attack? I mean in rpg game when a boss uses skills, normally thare will be circular or rectangular red areas when the attacks will be launched
@peemmai76604 жыл бұрын
Can you change the circles to a Sector instead?????? Pliz tel me
@xy01576 жыл бұрын
great tutorials! also, writing in comments would be good for reinforcement
@feffo99086 жыл бұрын
quick question, how do you give name to collision level?
@Kidscancode6 жыл бұрын
Project Settings -> Layer Names -> 2D Physics
@ejoojoo4 жыл бұрын
Trying to use this on a kinematicbody but got an error "Invalid get index 'position' (on base: 'KinematicBody')."
@クリプトムネシア4 жыл бұрын
You need a KinematicBody2D
@memzen81016 жыл бұрын
If it is possible, maybe do a video about a pop up option menu on mobile devices that appears over any level which uses a minimum amount of cpu when it is not needed.
@froyorex48565 жыл бұрын
Please Make more videos ?
@Kidscancode5 жыл бұрын
I'm working on it. Any requests?
@froyorex48565 жыл бұрын
@@Kidscancode please make a rocket that follows you and explodes upon contact. Please ! I wanna participate in my first game jam.
@froyorex48565 жыл бұрын
@@Kidscancode smooth following rocket. With explosion particles.
@Kidscancode5 жыл бұрын
I did that in my tank project: kzbin.info/www/bejne/gXK4gWekoa-ssJI
@OmegaF776 жыл бұрын
Could you do a tutorial on how to cast shapes? For example, Unity 3D has a kind of raycast called, "SphereCast." It casts a sphere wherever it's pointing. This is perfect if you want to make your own character controller.
@EightNineOne6 жыл бұрын
This is immensely useful. Thank you so very much.
@JeanVermeersch5 жыл бұрын
Great tutorial, thanks a lot! :) Question: Do you think we can use raycast2d aswell for something else, like doing a wall jump for example?
@Kidscancode5 жыл бұрын
Certainly. Raycasts have lots of uses. That's one common use of a raycast, although a shape might work better to detect touching a wall. There is also "is_on_wall()".
@JeanVermeersch5 жыл бұрын
@@Kidscancode Oh great, thanks you very much! I thought it was possible but I was kinda unsure about it! :)
@johnharbinger46375 жыл бұрын
or you could just create a custom collision bounding box shape one for detect and another for shoot. no rays. no masks. a lot less code (but wouldn't be able to use in different environments without hand making a new detect collision box shape for each placement if positioning to obstacles is different ) just thought be good to mention alternative pro and con.
@mikaelkihlstrand4 жыл бұрын
Really nice stuff, thanks for this!
@wasimkabir43986 жыл бұрын
Hi Chris! You are awesome!! Could you please make tutorial on creating a top down tile based game in godot 3 (like that you have made for pygame or something new)?
@JAAAA09383-Y3 жыл бұрын
THANK YOU I WAS STRUGGLING TO DO THISS
@stryker45144 жыл бұрын
Whenever I place my enemy and player character under a Ysort node the detection for the enemy npc doesn't work at all (no lines being drawn). Although if I move it oustide of the Ysort node everything works fine.
@classicguy78134 жыл бұрын
Can we draw 3d lines draw_line()?
@FeniksGaming6 жыл бұрын
Great video as always
@cesarfernandez23686 жыл бұрын
Hello do you any tutorial for light2d? I know the basic but I would like to learn how to do nice light effects
@Kidscancode6 жыл бұрын
Yes, Light2D would be a good one. Have you looked at the code from the official demos?
@cesarfernandez23686 жыл бұрын
no, not yet. I'm going to see it later thanks.
@rafaeu2923 жыл бұрын
Is there a way, to make a Circular Raycast, or make a Raycast do an instant 360? Because im trying to make a Granade and it would be really helpful for the explosion
@Kidscancode3 жыл бұрын
I'd use an Area2D or `Physics2DDirectSpaceState.intersect_shape()`
@rafaparanhos62854 жыл бұрын
When I try to run it, it says : invalid index 'shape' (on_base: 'null instance') with value of type 'CircleShape2D'.
@t.h.mgaming41283 жыл бұрын
That happens due to files being strange or due to corruption, try restarting your computer or restarting Godot
@Rudyaification5 жыл бұрын
Nice tutorials mate. Got one issue, when i'm using narrow rectangle, it's doesnt work properly.
@Kidscancode5 жыл бұрын
I don't really understand your question. What do you mean by "properly"? What goes wrong? What rectangle is narrow?
@Rudyaification5 жыл бұрын
@@Kidscancode I'm trying to use your concept in my game. Your project works just fine. But in my case i can't get full rotation, it's only works from the left side of the screen. Then i took your code, with all signals, masks... and got the same result. Trying to figure out what is going wrong. Narrow rectangle is like 10 by 70
@Rudyaification5 жыл бұрын
@@Kidscancode Figured out what was wrong. Offset. Just forgot about it. Your code works perfectly! Thanks
@moric46775 жыл бұрын
can't we do all of this by creating a raycast2d node?
@3DSNC4 жыл бұрын
thanks for the tutorial, that was amazing
@askaranarbekov31456 жыл бұрын
how did you make the bullets fly out? I do not even have the mob to spin, although I did everything like you
@Kidscancode6 жыл бұрын
Did you connect the shoot signal?
@tomandrieu38766 жыл бұрын
Hey men great tutorial, i search on internet and didn't found how to properly set up the collision mask and i end up with my result.collider.name always returning "EnnemyArea" wich is an area for making my ennemy collinding with a bunch of stuff, my raycast seems to hit this area first. I think if i set up correctly my layerMask it should work but i don't find any tutorial for godot 3 may you help me ?
Thanks man, i got it work with exclude everything in the intersect_ray() method. If i understand correctly i have now two layers name player and ennemy, on my player kinematicBody i set the layer to Player and the mask to Ennemy and the opposite for the Ennemy kinematic body and it will work great ?
@joshdoesthings78366 жыл бұрын
Keep it up man. Once I start making money, I'll donate brother. But until then thank you
@aleksanderzajkowski82856 жыл бұрын
"Indentifier not found: pos" in shoot(pos) i dont understand why :( Can someone help??
@Kidscancode6 жыл бұрын
That means you haven't declared a variable named "pos". Perhaps you made a typo?
@TheFAA2136 жыл бұрын
great tutorial ! I was wondering will you do python again ?
@Kidscancode6 жыл бұрын
Sooner or later. There's lots of Python material out there already, and not as much for Godot, and I've gotten very involved with the project so it's my focus right now.
@Condetg6 жыл бұрын
Hey man. Really thanks for all your tuts. They're insanely good. But for this one it's a bit different. It's good and all, but I'd like to know how it works. So I wanted to reverse-engineered your script. I made a blank project, setup a new character who have different properties than yours. I exported the turrets from your projet and tried to tweak it to make them able to recognize my character... But couldn't make it happen. The turrets don't target this new character of mine and I can't figure out why. For testing purpose I tried to import the character from the ray-casting project to my own... The turrets are able to aim him but do not shoot anything. Is that because importing things from a project to another is broken, or is there specific things in your Main scene or Player that make it works ? I'm going to make turrets step by step after that. But I wanted to try to tweak it a little before trying to code it by myself because I'm a complete beginner with Godot... Once again, thanks for your great tutorials.
@Kidscancode6 жыл бұрын
Most likely you didn't set up your collision layers like I did, and that's why the turrets don't see the player. This really wasn't intended as a beginner-level demo, which is why I didn't go too deeply into the initial setup. It was specifically to talk about the raycasting technique as applied to a common problem.
@Condetg6 жыл бұрын
Oh, I see. That's pretty instructive anyway. Going to look at it in depth. And... Thanks for your answer btw. :)
@aleksanderzajkowski82856 жыл бұрын
The thing is i only wanted to do shooting (by main player) and i only use some of your code, and i didn't see var/const pos, so i think it is declared in some other way, dont know where
@Kidscancode6 жыл бұрын
It's a loop variable. "for pos in..."
@aleksanderzajkowski82856 жыл бұрын
Oh, thanks
@suretmeyenateistoc42523 жыл бұрын
please make raycast3d tutorial :(
@gitprophet5 жыл бұрын
Great explanation. thanks
@av088r6 жыл бұрын
How would I go about scaling this down to 32x32 tiles? I have tried but the raycast messes up and hits walls before it actually collides with them.
@Kidscancode6 жыл бұрын
Tile size should not matter. However, you can't just scale a TileMap - you have to use 32x32 tiles.
@av088r6 жыл бұрын
@@Kidscancode I changed the tilemap cell size to 32 along with editing the icon.png down to 32x32 and fixing all of the scalings of the turret and player but now the ray is stopped by some invisible collider I can't find. Here is what I am seeing: imgur.com/VwBnBEr
@Kidscancode6 жыл бұрын
The TileSet itself needs to be rebuilt with 32x32 tiles and collisions. You're using tiles with 64x64 collisions on a 32x32 map.
@av088r6 жыл бұрын
@@Kidscancode I had to reimport the icon.png to get it to see that it was 32x32 and fixed the shape offset. I am very new to this engine and am trying to learn stuff as I need it.
@muthukrish13186 жыл бұрын
i could not get the result.collider.name to be compared with the player object. is there any solution to it.. i used player_node = get_parent().get_node("Player") could not compare if result.collider.name == player_node or "Player" or player_node.get_node("PlayerBody") #its collision name could u help me out ASAP.. Thanks in advance..
@Kidscancode6 жыл бұрын
What does "could not get it to be compared" mean? Did you get an error message? Was your code identical to the code in the tutorial? I can't suggest a solution without knowing what the problem is.
@touqui86592 жыл бұрын
i get : Script inherits from native type 'CollisionShape2D' so it can't be instanced in object of type 'Area2D' when i run my game now :(
@Kidscancode2 жыл бұрын
You seem to have taken a script that starts with "extends CollisionShape2D" and attached it to an Area2D. A script attached to an Area2D must start with "extends Area2D".
@touqui86592 жыл бұрын
@@Kidscancode yeah exact ty man 😋
@Romeoill6 жыл бұрын
thank for the best video ever in your channal i like it THAKYOU ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ i love this channel
@OsamaBombLyrics5 жыл бұрын
First off thank you very much for taking the time to make these videos. Is this compatible with 3.1? I got to the section about adding the directions and received and error on this line: var ne = target.position + Vector2(target_extents.x - target_extents.y) The error reads as follows: error(34,29): No constructor of 'Vector2' matches the signature 'Vector2(var)'. If anyone reads this and/or replies I appreciate it.
@nailbomb4205 жыл бұрын
You're missing the comma between the two numbers in your vector2. The y is supposed to be negative, not taken away from the x
@OsamaBombLyrics5 жыл бұрын
Thank you very much for your response. I've been staring at this code for far too long. Hey so on line 27 he has the following line: var target_extents = target.get_node('CollisionShape2D').shape.extents - Vector2(5, 5) Would this still work with a CollisionPolygon2D? @@nailbomb420
@nailbomb4205 жыл бұрын
@@OsamaBombLyrics No it wont work with a polygon, it's specific to the rectangleshape2d, i.e they're different properties for the different shapes, circleshape2d has radius instead for example. If you used polygon for no real reason, just swap it to a rectangleshape2d, if the polygone is fairly important to the shape of your character, then consider adding an area2d with a rectangleshape and using that for basic stuff like this. When it comes to most collision you will find it much much easier to use rectangles or circles, as the maths is quite simple to figure out intersections. Ass soon as you start to rotate things or use odd shapes it means either alot more more work, or higher level of maths :/ (which is annoying) So I suggest using rectangles where possible. Note, that you can make the rectangle much smaller than the size of the sprite, i.e many 32x32 sprites can have rectangleshape colliders 16x16 or some other dimensions. Hope this helps.
@nailbomb4205 жыл бұрын
@@OsamaBombLyrics here's a link to the polygon2d class documentation: docs.godotengine.org/en/3.1/classes/class_polygon2d.html the polygon does store all the points that define it, so you could in theory get that list of points and use them instead of the rectangleshapes extents, as they're both just points in space. Might be worth checking out.
@OsamaBombLyrics5 жыл бұрын
@@nailbomb420 Yessss! I got it working! Thanks for the tip and responses! I just used another CollsionShape2D on the Player with its roll to specifically handle interacting with the Turret. I will probably take your advice and switch my CollsionShape2D's to either rectangles or circles. I was using the Polygon2D shapes because I wanted all the collisions to be as exact as I could make them. However, if it will be just a bigger headache in the long run I will just keep things simple. I'd rather have a working game then nothing at all.
@raremc16206 жыл бұрын
Hi. How could i contact you? I need some help with python.
@Kidscancode6 жыл бұрын
There's a link on my website to send me email. Or you can post here in the YT comments if it's a relatively short one. I can't promise I can help you, but I'll take a look.