Top Down 2D Shooting in Godot

  Рет қаралды 82,171

Code with Tom

Code with Tom

4 жыл бұрын

In today's video I'll show you how to create a top down shooting mechanic in godot.
If you've ever wanted to create your own top down shooter like a dual stick shoot em up then stick around and stay til the end.
Source: github.com/codewithtom/godot-...
Patreon: / codewithtom
Discord: / discord
Brackeys video in Unity: • TOP DOWN SHOOTING in U...

Пікірлер: 158
@GothicRK
@GothicRK 5 ай бұрын
Jesus man, I couldn't find ANYTHING like this anywhere, although it would be really appreciated if we could have a Godot 4 version. Thank you for explaining everything clearly!
@joelgarcia9670
@joelgarcia9670 4 жыл бұрын
Even though this vid is a bit old it really helped me out when I couldnt find a tutorial. Thank you so much man you're a god send
@neworderseo
@neworderseo 2 жыл бұрын
8:25 Gravity is applied to bullets and they fall down, which shouldn't happen in top-down perspective. Zero Gravity Scale on your RigidBody2D to avoid that.
@nicaraguandude9258
@nicaraguandude9258 Жыл бұрын
thanks
@nikukralizikane
@nikukralizikane Жыл бұрын
that was in a video 12:14
@syedrizvi6408
@syedrizvi6408 4 жыл бұрын
Fantastic tutorial You did a great job. Brackey is doing a great job too. First I started learning Unity, but then switched to Godot. Looks like many people are opting for Godot. It is a trend setter. Please make more videos.
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thanks for the feedback Syed, definitely have more videos to come!
@marasternensschnuppe4990
@marasternensschnuppe4990 4 жыл бұрын
Thank you been looking for something like this for ages! Brilliant video and explanation =)
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thank you Mara glad you liked it!
@weandi2171
@weandi2171 Жыл бұрын
Thank you so much I spent hours trying to get this working and hours more looking for a video, don't know why it took so long to find
@DoughnutBricks
@DoughnutBricks 2 жыл бұрын
Thanks very much! I am currently working o a topdown hunting game and this helped a lot! Continue the good work! 😀
@thedevine3756
@thedevine3756 4 жыл бұрын
What? What’s that? A tutorial that is perfect for the EXACT situation I’m in? Don’t mind if I do! Good tutorial 9999999999/10
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad you found this useful 😁
@azazelgaming6573
@azazelgaming6573 2 жыл бұрын
Exactly what i needed + nicely explained = 10/10
@johnnygossdev
@johnnygossdev 4 жыл бұрын
Fab tutorial Tom. Looks great!
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thanks Johnny!
@dj_theta_shade764
@dj_theta_shade764 3 жыл бұрын
Amazing stuff m8. Helped me a lot. Thank you.
@wahyuadi2985
@wahyuadi2985 4 жыл бұрын
Its so clear, easy to understand, thankyou for making this video 👌👌👌
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad you enjoyed it :)
@andrej4806
@andrej4806 3 жыл бұрын
Thank you dude, making my first game it is an platformer and u are some magician that is able to shoot fireballs and teleport upwards i juat couldn't figure out how to make the fireball
@godot-boy7694
@godot-boy7694 3 жыл бұрын
Well so kind of you sir. The video was well explained. Thank you very much.
@nuki_yt
@nuki_yt 4 жыл бұрын
I find it funny that I was doing a top down, but in all the tutorials the bullets were with RayCast. So I had to improvise, I suffered but I succeeded. and 10 minutes later you uploaded this video. Therefore my suffering was in vain. It's very funny
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Hah, if it's any consolation sometimes pushing through and finding your own solution is the best way to learn. I hope this tutorial proved useful to you still :)
@TasdiqueChowdhury
@TasdiqueChowdhury Жыл бұрын
You're so awesome -- thank you so much for this video!! Learned a ton
@bomb_jaguar
@bomb_jaguar Жыл бұрын
Thank you so much man, very enlightening!
@cooper_da_copper9468
@cooper_da_copper9468 3 жыл бұрын
Thank you! This vid helped me A LOT!
@user-kn5qr6wx6p
@user-kn5qr6wx6p 3 жыл бұрын
Thank you very much!This tutorial is very useful for me.
@ivanljujic4128
@ivanljujic4128 2 жыл бұрын
Very useful, thanks!
@kuroosen5122
@kuroosen5122 3 жыл бұрын
Nice tutorial! one question tho instead of the player rotating to aim will it be possible to just aim with just the mouse instead? without rotating the player. like if you are facing up you can shoot behind you something like that
@dachrismflvl666soieldiablo8
@dachrismflvl666soieldiablo8 3 жыл бұрын
awesomeee, i used this on my side scrollee and it works perfectly. Thankss
@fragarena9910
@fragarena9910 4 жыл бұрын
Nice, make more godot tuts like these where you take other engine tuts and convert it to godot tuts 👍 . There are so many great unity and unreal tuts but converting them to be usable in godot feels daunting 😥
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thanks Frag. Yeah I know what you mean. I intend to make more of these 😁
@fedev21
@fedev21 4 жыл бұрын
Nice video dude! Thank you so much!
@CodeWithTom
@CodeWithTom 4 жыл бұрын
You're very welcome 😊
@rishianands8472
@rishianands8472 4 жыл бұрын
So fast..!!!!! Thanks tom.... so useful
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Cheers Rishi glad you found it useful!
@thefruitman3200
@thefruitman3200 2 жыл бұрын
in enter the gungeon, the character sprite faces in different directions when aiming in a general direction, does anyone know how i could do that?
@jlewwis1995
@jlewwis1995 3 жыл бұрын
Doing Direction.x = input.get_action_strength("move_right") - input.get_action_strength("move_left") Direction.y = input.get_action_strength("move_down") - input.get_action_strength("move_up") Would be a much better way of getting the direction vector imo, it's the way I always use
@matchless-hq3tl
@matchless-hq3tl 4 жыл бұрын
You deserve more subscribers.
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thank you very much!
@RyanScottForReal
@RyanScottForReal 4 жыл бұрын
Thanks this really helped me!
@CodeWithTom
@CodeWithTom 4 жыл бұрын
You're welcome!
@elgatoamarillo
@elgatoamarillo 3 жыл бұрын
Thank you Tom!
@ftAnx
@ftAnx 4 жыл бұрын
That was very useful. thanks. 👍
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad you found it useful!
@theskullchild1975
@theskullchild1975 Жыл бұрын
I love programming, I search for the tutorials I want (shooting in 2d platformer) and I get what I kinda needed (shooting in 2d top down) true programming experience (good vied :) )
@ChrischoBoardgaming
@ChrischoBoardgaming 3 жыл бұрын
I suggest dealing also with those bullets that have not been queue_free()'d. I haven't run any benchmark tests yet, but I suspect that filling the computer's memory with hundreds or thousands of bullet instances that just flew out of the screen and weren't queue_free()'d might have an impact on performance sooner or later ;) I liked your using of apply_force(), which is rarely used in other Godot tutorials, although it's supposed to be one of the few methods to use in conjunction with rigid bodies.
@Maltebyte2
@Maltebyte2 Жыл бұрын
Thanks for this! How do we add sounds to shooting and explosions?
@AEShooter
@AEShooter 3 жыл бұрын
Thank you appreciate it
@lorenzoguzzo1354
@lorenzoguzzo1354 4 жыл бұрын
thank you very much,this video help me with a totally diferent melle mecanic
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Awesome! :)
@HenriqueDeodato
@HenriqueDeodato 4 жыл бұрын
hello, thanks a lot for the infos, keep the amazing work =)
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Hey Henrique, you're very welcome!
@arvindverma727
@arvindverma727 2 жыл бұрын
Nice tutorial I want the same thing to do in my game
@PedroLima-dd6zd
@PedroLima-dd6zd 3 жыл бұрын
Thank you
@BoobCheese
@BoobCheese 4 жыл бұрын
Good stuff
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thanks Bao!
@yourkodi3945
@yourkodi3945 4 жыл бұрын
hi friend, thanks very much for mentioning about brackleys version and this. Godot doesnt have tutorials like unity has brackleys, I am so glad you have done something similar to a brackleys tutorial. What is your view between unity and godot especially for noobs or beginners to coding?
@CodeWithTom
@CodeWithTom 4 жыл бұрын
I think they're both fantastic game engines, especially for beginners. Both have a great community and while Unity has a vast amount of documentation and tutorials, Godot is also picking up pace. Godot is definitely an engine to watch in 2020.
@jrayalac
@jrayalac 4 жыл бұрын
Hey, what type of node are the trees? I'm trying to replicate the scene in my computer. Thanks!
@chris_gamedev
@chris_gamedev 4 жыл бұрын
i think they are area2d
@SabeDoesThingsChannel
@SabeDoesThingsChannel 2 жыл бұрын
I love this video could you make a video like brackeys side scrolling shooting tutorial
@micha7349
@micha7349 3 жыл бұрын
when i tried to make the bullets disappear on colision it shows up with"Script inherits from native type 'KinematicBody2D', so it can't be instanced in object of type: 'RigidBody2D'" and also when im connecting the bullet it says "connecting from" so that might have something do do with it.
@Sebwazhere
@Sebwazhere 3 жыл бұрын
Is there a way to do this 3.2.3? Do I have to make another group for my zombie or do I have to change the code? (My bullet doesn't doesn't disappear and the explosion doesn't play)
@Anaflexys
@Anaflexys 3 жыл бұрын
cool videa man though the explosion apearsa little behind where the bullet hit. I've followed the tutorial exactly. Any help?
@cesarcontreras8786
@cesarcontreras8786 8 ай бұрын
Good tutorial. I'm making a tank turret, and I got the turret look at mouse, but I don't know how to make that movement smooth even if I move the mouse faster. How can i do that?
@infelicitas
@infelicitas 4 жыл бұрын
Hey man where ya been the past long while? i still need to learn more about that fps xD learning how to make projectiles for the guns is on the top of my list right now..
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Hey! Part 4 will be out very soon 😁
@infelicitas
@infelicitas 4 жыл бұрын
@@CodeWithTom Hey awesome man! can't wait xD
@GlorifiedPig
@GlorifiedPig 4 жыл бұрын
thanks a load, you make transferring from unity a breeze
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Awesome! Really glad I could help
@DomPeriod
@DomPeriod 4 жыл бұрын
bro wtf pig i didnt expect to find you here
@leoneverte
@leoneverte 4 жыл бұрын
COOL.. Man... DANKE!!!
@kamelmohammad1961
@kamelmohammad1961 4 жыл бұрын
Thank you for this great tutorial, but I noticed that you didn't multiply the player speed by delta, doesn't that make the player move with inconsistent speed on different devices because of the difference in frame rate ?
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Hey, the move_and_slide function gets multiplied by delta implicitly by the engine. This is different to the way move_and_collide functions however.
@kamelmohammad1961
@kamelmohammad1961 4 жыл бұрын
@@CodeWithTom aha , I didn't know that, thank you very much.
@Kamingos
@Kamingos 3 жыл бұрын
thanks you
@micha7349
@micha7349 3 жыл бұрын
how do you hide the console? or is it impossible once its up?
@animation4152
@animation4152 Жыл бұрын
hey, even when i add rotated(rotation) the bullets only go to the right of the player
@youssefkamadoi3124
@youssefkamadoi3124 2 жыл бұрын
tannk you sooooooooooooooo much !!!!!!!
@kurbonmirzoaliev9600
@kurbonmirzoaliev9600 2 жыл бұрын
Damn... trees in video games are a different breed...
@khusravkholmatov3667
@khusravkholmatov3667 2 жыл бұрын
Thx
@decisive2242
@decisive2242 3 жыл бұрын
There's something weird happening to me, the script was working the first time but after the first test they started not being sent with velocity but just kinda being pooped out of my ship
@kochukrissten8533
@kochukrissten8533 2 жыл бұрын
I made a separate gun and typed the same bullet script. Every time I try to shoot, the bullet only moves forward in the x axis, no matter where my mouse cursor is pointing. How can I fix this? Thanks.
@Cleoseni
@Cleoseni Жыл бұрын
dirt blort development sent me here!
@Cleoseni
@Cleoseni Жыл бұрын
no way?
@UnknownedYt
@UnknownedYt 2 жыл бұрын
do you know how to add sounds when it hits?
@Eagles_Eye
@Eagles_Eye Жыл бұрын
i have an issue, when i walk with my player and i turn my player, the bullets fly in different direction than my mouse.
@rahulc4281
@rahulc4281 4 жыл бұрын
This was fantastic! One thing you would have added is screen wrap, that is if tank goes out of screen from one end it comes back from another opposite end. I absolutely loved this tutorial otherwise.
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Thank you so much 😁
@PolskiMrKrabs
@PolskiMrKrabs 2 жыл бұрын
just a quick question, i did everything what you told to, but my bullet shoots from my cursor xD, any idea how to repair it ?
@mirzobeksultonnazarov976
@mirzobeksultonnazarov976 4 жыл бұрын
7:10 - how to use the - rotated() - function in 3D? it need tow parameter: axis and phi. I add another node to player scene Bullet direction and put it farther in front of Bullet position and write my code like this: if Input.is_action_pressed("fire"): var bullet_instance = bullet.instance() bullet_instance.translation = $Bullet_position.get_global_transform().origin bullet_instance.apply_impulse(Vector3(), $Bullet_direction.get_global_transform().origin - $Bullet_position.get_global_transform().origin) get_tree().get_root().add_child(bullet_instance) it works but how to use by the rotating function?is it possible?
@fragarena9910
@fragarena9910 4 жыл бұрын
👌
@aeolian951
@aeolian951 3 жыл бұрын
How do I rotate bullets without rotating the player?
@ccristian1715
@ccristian1715 4 жыл бұрын
Thanks for the tutorial. I used it for a Side Scroller. The only problem I have is the bullet_speed that fluctuates when the user shoots and moves in the same direction. Any tips on how can I fix this issue?
@nemene8585
@nemene8585 3 жыл бұрын
I have the same problem. I tried updating the mouse angle but still doesent work.
@nemene8585
@nemene8585 3 жыл бұрын
I was searching for a comment like this in hopes of finding a fix :(
@nemene8585
@nemene8585 3 жыл бұрын
still no anwser :(
@nemene8585
@nemene8585 3 жыл бұрын
you have to call the yeet in the procces of the bullet in a if statement that is canceld at the end of it
@B-mo0000
@B-mo0000 4 ай бұрын
@menoobsad
@menoobsad 3 жыл бұрын
hey for me it said nonexistent function 'instance' in gdscript how do i fix this
@kleydermendoza4771
@kleydermendoza4771 3 жыл бұрын
Hi, i need, your help, im spanish, then sorry for my english :v, when I make the group "player", and I do the function of the bullet, from, "if it is not in the group player: queue free", but when it collides with a tree, nothing happens, it keeps bouncing, the tree is a sprite and a static body2d 13:27
@DavidTorres-yo4vb
@DavidTorres-yo4vb 3 жыл бұрын
para empezar tienes que conectar el objeto con un: " on_Area2D_body_entered " y ponerle : if " introduce el nombre del objeto " in body.name: ... y después ponle un queue free, esto si el objeto esta en la misma escena que el otro xd... o bueno así mas o menos me funciona no se si te llegue a funcionar...
@Dorniotos
@Dorniotos 2 жыл бұрын
It says Invalid call. Nonexistent function 'apply_impulse' in base 'KinematicBody2D'. Every time I try to shoot. Pls help me.
@awesomegamingmixes114
@awesomegamingmixes114 4 жыл бұрын
It says Invalid.call Nonexistent function 'apply_impulse' in base 'Node2D'. What can i do about it ?
@herre3147
@herre3147 4 жыл бұрын
Looks like you used a Node2D as a root node for your bullet instead of a Rigidbody2D. Right click on your Node2D of your bullet scene, click "Change Type" and change it to "Rigidbody2D"
@AleksandarPopovic
@AleksandarPopovic 4 жыл бұрын
Thanks to sugestion on unity tutorial but godoto is best engine ever.......special for 2d games.......thank you for sharing this turorial, nice work subscribe from me, continue to work people must interested on godot.......thank tou onece again great video......
@CodeWithTom
@CodeWithTom 4 жыл бұрын
You're very welcome! 😁
@ragnarhagberg6716
@ragnarhagberg6716 3 жыл бұрын
Invalid call. Nonexistent function "rotated" in base "Nil", any ideas why? This occurs when applying impulse
@simonrobertgreenwood
@simonrobertgreenwood 3 жыл бұрын
Make sure your brackets on line 15 are the same as his that fixed it for me
@russelsantos2729
@russelsantos2729 2 жыл бұрын
Hi, How can I make it run out of ammo??
@williamnilsson4344
@williamnilsson4344 4 жыл бұрын
For me i don’t have a function called apply_impulse(), is there an alternative or can I fix it somehow?
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Are you using a KinematicBody?
@arianmanchurin7149
@arianmanchurin7149 4 жыл бұрын
@@CodeWithTom Yes, KinematicBody
@CodeWithTom
@CodeWithTom 4 жыл бұрын
@@arianmanchurin7149 Gotcha, so you need to be using a RigidBody2D instead. :)
@abahanparichha2780
@abahanparichha2780 2 жыл бұрын
in godot 3.3 get_global_position( ) not exists. are they removed that function
@nuki_yt
@nuki_yt 4 жыл бұрын
Hi, I have a problem. I created a script on the bullet to be destroyed after 10 seconds, everything works normally, but when it disappears, the game slows down and I don't understand why. Can you help me? Here is the Code. var life = 10 func _process(delta): yield(get_tree()create_timer(life), "timeout") destroy() func destroy(): queue_free()
@nuki_yt
@nuki_yt 4 жыл бұрын
Forget it, I already solved it :)
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad you managed to solve the issue Nuki!
@charmilla5098
@charmilla5098 4 жыл бұрын
@@nuki_yt how you solved it
@yourkodi3945
@yourkodi3945 4 жыл бұрын
@@nuki_yt maybe post what you done to help others??
@nuki_yt
@nuki_yt 4 жыл бұрын
@@yourkodi3945 The problem was in the yield(), sometimes it was executed when the bullet was deleted, and that caused lag. I fixed it using a timer node.
@nemene8585
@nemene8585 3 жыл бұрын
When i am moving and shooting the bullet goes nuts and shoots in a wrong direstion idk how to fix it
@nemene8585
@nemene8585 3 жыл бұрын
found the anwser you have to call the yeet in the bullet scene on proces in a if statement that is canceled at the end of itself
@user-ic3tg7gb8z
@user-ic3tg7gb8z Жыл бұрын
my bullet doesnt have any applied force to it?
@el21es37
@el21es37 3 жыл бұрын
I get this error : invalid call, Nonecistent fuction "apply_impulsive" in base "rigibody2D" (bullet.gd)
@toadyproductions2106
@toadyproductions2106 3 жыл бұрын
your supposed to put impulse not impulsive.
@CiampaGiuseppe8
@CiampaGiuseppe8 4 жыл бұрын
It gives me an error. It says: "Invalid call. Nonexistent function 'instance' in base 'StreamTexture'."
@thedevine3756
@thedevine3756 4 жыл бұрын
Huh, that odd. I don’t know why it does that I’m just replying to make the comment more popular so he can see it. Good luck!
@ianbrown3689
@ianbrown3689 4 жыл бұрын
I've got the same thing
@ianbrown3689
@ianbrown3689 4 жыл бұрын
ok, I figured it out. The sprite that's being preloaded MUST be a different scene. It doesn't work other wise (make sure your bullet sprite is a .tscn file)
@aurensmith4292
@aurensmith4292 4 жыл бұрын
I had the same problem but it was because I used .gd instead of .tscn lol
@mirzobeksultonnazarov976
@mirzobeksultonnazarov976 4 жыл бұрын
Is your bullet object is type of RigidBody? i mean the main node of the bullet scene should be RigidBody not StreamTexture.
@samuelzhang5497
@samuelzhang5497 4 жыл бұрын
It says "Invalid call. Nonexistent function 'apply_impluse' in base 'RigidBody2D' This shows up every time I left click when playing the project. Could someone help me out?
@jjlolbutnotreally
@jjlolbutnotreally 3 жыл бұрын
you spelled impulse wrong?
@nemene8585
@nemene8585 3 жыл бұрын
Maybe you changet the mode from rigid to static or character or kinematic. Or you switched to kinematc body and it is just named rigid idk.
@tylerreynolds5126
@tylerreynolds5126 2 жыл бұрын
or just do "if Input.is_action_just_pressed('fire')"
@l-tdrake9565
@l-tdrake9565 4 жыл бұрын
This code doesn't work for me : "fire_instance.apply_impulse(mov, Vector2(fire_instance, 0).rotated(rotation))"
@tuhkiscgibin6627
@tuhkiscgibin6627 4 жыл бұрын
I have the same problem
@l-tdrake9565
@l-tdrake9565 4 жыл бұрын
@@tuhkiscgibin6627 I figured it out
@krspy8849
@krspy8849 3 жыл бұрын
@@l-tdrake9565 you probably should have told him how you fixed it...
@splotchy6759
@splotchy6759 4 жыл бұрын
I followed this but in the end it spawns 3 bullets and when i shoot down it spins out, anyhelp? Edit: Fixed it!!!!!!!!!!!!!!!!!!!
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad you got it fixed
@nabilizard704
@nabilizard704 3 жыл бұрын
Asset?
@toby1kanobi194
@toby1kanobi194 3 жыл бұрын
LMAOOOO I forgot the _ at the start of _physics_process(delta): and i couldnt figure out why it wasnt working
@VickylanceMedia
@VickylanceMedia Жыл бұрын
Area2D will be better in terms of performance for bullets
@SoyPikZG
@SoyPikZG 2 жыл бұрын
ayuda, solo me dispara hacia la derecha :,v
@SantiDEV_CR
@SantiDEV_CR Жыл бұрын
A mi cuando presiono para disparar se me cierra el juego ☠️
@gonzitarod2885
@gonzitarod2885 3 жыл бұрын
Totalmente genio ! Gracias hermano. No traduscas esto en el traductor de gugul xd
@kleydermendoza4771
@kleydermendoza4771 3 жыл бұрын
wtf, eres de colombia?
@pgt915
@pgt915 3 жыл бұрын
How nontrivial is for godot users to make the player look at the mouse! I would have to write 1000 lines of code just for this one simple thing in unity.I will say that since brackeys stopped making videos,I've stopped using unity and godot is so much easier to use!
@joshaklese4969
@joshaklese4969 Жыл бұрын
If you get halfway... there you are. Now I made the bullet already and I will not show you how it is put together and skip ahead and there you have it. Now go read the comments of everyone who made it through 100% with no snags singing the praise of the content creator.
@spasannobudd8937
@spasannobudd8937 2 жыл бұрын
dude slow down omg
@VaSoapman
@VaSoapman 3 жыл бұрын
This might just be me, but I hate GODOT signals. It feels a bit too much like the baby coding mode from GMS.
@martindelgado135
@martindelgado135 Жыл бұрын
alguien me puede ayudar tengo un dilema con un Sprite en resumen es un personaje con función de pesca el cual se puede mover de izquierda a derecha y puede lanzar balas en forma de anzuelo el problema es que no puedo integrar la animación de cuando saca la caña siempre que le doy a n se queda estático sin mostrar la animación adjunto código que use (copie) no se nada del lenguaje xd lo hago por un proyecto de grado xd extends KinematicBody2D const moveSpeed = 25 const maxSpeed = 50 const jumpHeight = -300 const up = Vector2(0,-1) const gravity = 15 onready var sprite = $Sprite onready var animationPlayer = $AnimationPlayer onready var preBullet = preload ("res://escena//bullet.tscn") var motion = Vector2() func _physics_process(_delta): motion.y +=gravity var friction=false if Input.is_action_pressed("ui_right"): sprite.flip_h = false animationPlayer.play("Walk") motion.x = min(motion.x + moveSpeed, maxSpeed) elif Input.is_action_pressed("ui_left"): sprite.flip_h = true animationPlayer.play("Walk") motion.x = max(motion.x - moveSpeed, -maxSpeed) else: animationPlayer.play("Idle") friction = true if is_on_floor(): if friction ==true: motion.x = lerp(motion.x,0,0.5) else: if friction ==true: motion.x=lerp(motion.x,0,0.01) motion = move_and_slide(motion,up); if Input.is_action_just_released("leftClick"): var bullet = preBullet.instance() get_parent().add_child(bullet) bullet.position = self.position bullet.rotate(self.rotation) if Input.is_action_pressed("n"): animationPlayer.play("launch")
@andrmiw9
@andrmiw9 2 жыл бұрын
Very useful, thanks!
@PeritoProducciones
@PeritoProducciones 4 жыл бұрын
Thank you! Very useful!
@CodeWithTom
@CodeWithTom 4 жыл бұрын
Glad to hear that!
We made Vampire Survivors BUT in 10 Lines of Code
7:08
PlayWithFurcifer
Рет қаралды 1 МЛН
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 23 МЛН
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 4,3 МЛН
WHO DO I LOVE MOST?
00:22
dednahype
Рет қаралды 80 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 14 МЛН
Make Your First Game in Godot in 2020
39:38
Code with Tom
Рет қаралды 52 М.
Godot 3.0: Top-down Tank Battle - Part 1
19:36
KidsCanCode
Рет қаралды 104 М.
Godot 4 Top-down Controller in Mins
16:43
rayuse rp
Рет қаралды 5 М.
How To Make a Space Shooter in 20 Minutes (Godot Engine)
23:04
Kaan Alpar
Рет қаралды 31 М.
Godot 3.0: 2D Visibility with Ray-casting
22:22
KidsCanCode
Рет қаралды 69 М.
Making Minecraft from scratch in 48 hours (NO GAME ENGINE)
16:38
Switching from Unity to Godot: The Definitive Guide
46:11
Code with Tom
Рет қаралды 17 М.
I Made a Desktop Pet in Godot
16:02
RachelfTech
Рет қаралды 87 М.
Master the GODOT TileMap tool in 15 Minutes!
13:23
Andrew Hoffman
Рет қаралды 37 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 23 МЛН