Godot 3.0: Rigid Bodies

Поділитися
Вставка
  • Опубліковано 21 січ 2025

КОМЕНТАРІ • 102

  • @adhamsafihi
    @adhamsafihi 7 років тому +38

    This all tutorial series by you are as good as paid tutorial out there! You deserve more views and subscribers! Thank you for your teaching and hope to see what's coming next. Happy New Year!!

    • @itsproyo
      @itsproyo 7 років тому

      I just subscribed ^.^ Your statement was spot on, dude is a beast!

    • @adhamsafihi
      @adhamsafihi 7 років тому

      Yes absolutely! Tell to all of ur relatives to subscribe him! Fantastic premium content to learn on youtube!

  • @saultoons
    @saultoons 5 років тому +2

    This was the best tutorial I have come across! Prior to this I was messing about with Kinematic Body 2D trying to get my click+drag movement to work and it was a nightmare, this video solved all my issues in no time. Thanks a lot!

  • @celsladroma8048
    @celsladroma8048 6 місяців тому

    6 years still this video can help me alot.. Thanks you for help my game can survive, otherwise my game would end up in garbage..

  • @MicahT
    @MicahT 7 місяців тому

    This is by far the best explanation of RigidBody2D I've found. Makes so much more sense now. I'm hoping enough of this translates to Godot 4. Thanks!

    • @Kidscancode
      @Kidscancode  7 місяців тому +1

      There are some minor changes in the syntax, but the concepts remain the same.

  • @skepsys_d
    @skepsys_d 7 років тому +4

    Very helpful! As always, great looking out for everyone. This has been a great year for learning Godot and I can't wait to see what is to come. Thanks a ton and have a Happy safe Holiday!

  • @alexi2706
    @alexi2706 11 місяців тому

    For whatever reason, I feel your code is super clean

  • @JustAnotherAlchemist
    @JustAnotherAlchemist 5 років тому +12

    5:36
    ...balls...
    ... and that concludes my TED talk.

  • @sablesanctum
    @sablesanctum 7 років тому

    These tutorials are by far the best I've seen. So easy to follow and understand.

  • @enigmatoons3622
    @enigmatoons3622 3 роки тому

    Could you update this, please? set_applied_torque don't exist any more.

  • @wolliel
    @wolliel 6 років тому +3

    Thank you, I found this quite informative. This is the basic sort of stuff that beginners like me really need.

  • @quantumthoughts7541
    @quantumthoughts7541 2 роки тому

    When talking about the custom integrator the documentation indicated collision response is not overridden. How could one apply a static friction or minimum collision force for movement requirement?

  • @Wonkabonka
    @Wonkabonka 3 роки тому

    one question, i really liked the click ball one, but how would i do it if i wanted to be able to click (only) when the ball is still and not moving?

  • @ujjalshill6442
    @ujjalshill6442 7 років тому +3

    Happy new year to you🔝

  • @madhavaprasath3904
    @madhavaprasath3904 4 роки тому

    i have a doubt how can i use a ragdoll using it pls reply fast

  • @Xorxelbee
    @Xorxelbee 5 років тому +1

    Thank you very much for this. Your way of explaining is fantastic. Clear, really helpful and calm - I love it. :)

  • @tryoung524
    @tryoung524 5 років тому

    How would I change the position of a rigid body 2D manually from a different object's script? I don't have access to the objects physics state directly

    • @Kidscancode
      @Kidscancode  5 років тому +1

      Send a signal to the rigid body with the new position, and let the rigid body set its position in _integrate_forces()

  • @silkworm2595
    @silkworm2595 5 років тому +1

    Hi. My game needs to involve a directly controlled player character influencing the physics of all enemies, and likewise the enemies to the character.
    Are there gonna be any drawbacks to this endeavour from the outset? What's gonna be limiting?

    • @Kidscancode
      @Kidscancode  5 років тому

      That's impossible to say. Just start making it and see what happens. If any bottlenecks appear, that's when you should worry about addressing them.

    • @silkworm2595
      @silkworm2595 5 років тому

      @@Kidscancode thanks a lot

    • @silkworm2595
      @silkworm2595 5 років тому

      @@Kidscancode just occurred to me that might have come off as sarcastic. To clarify thanks for the help lol

  • @r3pentandl1v39
    @r3pentandl1v39 4 роки тому

    Is the ship supposed to have gravity? Because whenever I start the scene, the ship starts going down the screen.

    • @ZenoDovahkiin
      @ZenoDovahkiin 4 роки тому

      You can either go into Project settings and set the default gravity vector to (0, 0), which will completely turn off gravity, or set the ship's gravity scale to 0, which will make the ship specifically immune to gravity.

    • @r3pentandl1v39
      @r3pentandl1v39 4 роки тому

      @@ZenoDovahkiin oh ok

  • @beaverliten
    @beaverliten 5 років тому

    Is there a way to make the click and drag only work if you are clicking on the ball ?

    • @Kidscancode
      @Kidscancode  5 років тому

      Of course, you have to check how far you've moved the mouse versus the size of the ball.

    • @usualatoms4868
      @usualatoms4868 5 років тому

      @@Kidscancode Could you explain this in more detail?

  • @awiggan1
    @awiggan1 7 років тому +3

    Great tut! Keep up the great work. Very helpful.

  •  7 років тому

    Is there any way to change the gravity/friction axis? in case I'm doing a top-down game and needs the physics

    • @Kidscancode
      @Kidscancode  7 років тому +1

      "Default Gravity Vector" in Project Settings -> Physics -> 2D. Note you can also use Area2D to override global physics properties as well.

  • @jerfersonmatos28
    @jerfersonmatos28 7 років тому

    Hello, kidscancode, I have a problem, I was reading the documentation on the kinematics page in this adress: docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html and I've followed everything in the same way, but when I run the scene the player just falls and walks very very very slow, I've tried with your videos as well but the same happens. The player and the gravity are very slow. I don't if it's a bug of the new version (rc3)

    • @Kidscancode
      @Kidscancode  7 років тому +1

      I took a look and the error is in the document. "move_and_slde()" handles delta internally, so you shouldn't multiply velocity by delta. This is documented in the KinematicBody2D docs.

    • @jerfersonmatos28
      @jerfersonmatos28 7 років тому

      Thank you, it works now

  • @MrTravoltino
    @MrTravoltino 6 років тому

    I noticed that engine_thrust always moving ship only in the right direction. Can i move ship in the vertical direction by code?

    • @Kidscancode
      @Kidscancode  6 років тому

      I'm not sure what you mean. We set up the thrust to always point in the direction the ship is facing. Do you only want it to go upward no matter which way the ship faces?

    • @MrTravoltino
      @MrTravoltino 6 років тому

      No, in the function of this tutorial's script you wrote "if Input.is_action_pressed("ui_up"): thrust = Vector2(engine_thrust, 0)", and you changed a rotation degree of the ship's sprite to 90, so it will match direction of the ship. You didn't pointed ship up, you rotated the texture to right. I wonder, why this func points ship exactly in the right direction at game's start? Not in the left, down, etc. Except of this right-pointing, this script could fit well for some lander-genre game. I was puzzled by this, but already solved the problem, just rotated ship's RigidBody to -90.

    • @Kidscancode
      @Kidscancode  6 років тому +1

      In Godot's coordinate system, zero degrees points to the right (along the x axis). So the rigid body is already pointing in that direction when its rotation is 0. However, to make the texture match that, we rotate the texture to match. Glad you found a solution to your problem.

  • @retrobeastgames
    @retrobeastgames 7 років тому

    I wish i had a teacher like you at school, love you videos, thank's

  • @nocodegamedev
    @nocodegamedev 7 років тому

    Hi, I've copied the code from the written version for the thrust and rotation section and the rotation does not work for me. The thrust is fine. I wonder if you can offer any advice on where to look for a problem with the rotation. As I mention, I copied and pasted the code directly from the written version. Thanks for a great tutorial.

    • @Kidscancode
      @Kidscancode  7 років тому

      Copy-and-paste from the web can sometimes lose formatting information, so you might need to check whether things are in the right place, especially when it comes to indentation. Other than that, I can't really speculate - I don't have enough information. Maybe try putting a print() statement after the keypress detection and see if it prints when you press the left/right arrows.

    • @christopherevans765
      @christopherevans765 6 років тому +1

      This is old, but I had the same issue. Found out that I had the RigidBody2D mode set to `Character` when it should have been set to `Rigid`.

  • @hookflash699
    @hookflash699 6 років тому +2

    I've always wondered: Why does Godot (and Unity as well, for that matter) allow rigid bodies and collision shapes to be scaled if it's never a good idea to scale them?

    • @kiloneie
      @kiloneie 5 років тому

      There has to be a reason, but i don't know it either...

    • @TheCivildecay
      @TheCivildecay 5 років тому

      3.1 removed that ability

  • @awiggan1
    @awiggan1 7 років тому +1

    One question. I have downloaded the suggested Art Pack & imported the sprite sheets. Is there a way to slice the part of the sprite sheet I want?
    PS - Apologies for the noobish question.

    • @Kidscancode
      @Kidscancode  7 років тому +1

      Sure. You drag the sheet onto the texture field of the Sprite. Then you check the box marked "Region" to On. Now you can click on the "Texture Region" panel at the bottom of the screen to select the region of the sheet you want to use.

    • @gonzo191
      @gonzo191 7 років тому +2

      Also there is now an auto slicing option in the "Texture Region" panel from the Snap Mode. Once done simply click on the slice you want.

  • @j.d.waterhouse4197
    @j.d.waterhouse4197 7 років тому

    When including a projectile for shooting down rigid bodies, but easily moved by code, it's best to use kinetic, right? i bring this up, because I think many game makers would want to know this when they want a gun or cannon which will realistically knock down block walls, etc.
    I made a shooter using a node 'projectile_container' in the main scene which created a new kinetic body projectile whenever the previous one has been shot. I added gravitation and movement and it works fairly well so far, but Any input would be appreciated!

    • @Kidscancode
      @Kidscancode  7 років тому +2

      You can use just about any type - it depends what you're going for. Often for bullets I prefer to just use Area2D since they're going to just detect the hit and disappear. If you want gravity/bouncing/etc, a rigid body might work better for you. In gamedev there are often multiple solutions to a problem.

    • @j.d.waterhouse4197
      @j.d.waterhouse4197 7 років тому

      Hey thanks so much. I originally tried using rigid body cannon shells, but i couldn't figure out how to get them to go to a particular location ( where ever the tank happened to be located) when they were spawned. I'd prefer rigid body since their gravity and bouncing would look more realistic when bouncing off buildings or blocks. There is no set_pos function for rigid body, right? So how would you spawn a child at a particular location the moment the player presses the space bar to fire?

    • @j.d.waterhouse4197
      @j.d.waterhouse4197 7 років тому +1

      Well, had I watched the video till the end, the answer to my question was already in the video, namely which is using get_transform and set_transform for rigid body

  •  7 років тому

    You show in the video a new way to do a asteroid clone. Should we use this approche or use a Area2D like you did in the asteroid tutorial ?

    • @Kidscancode
      @Kidscancode  7 років тому +1

      You can - it's got pros and cons. If it's working fine, it's not really worth switching. I did find it worked better to use Rigidbody2D for the asteroids themselves.

  • @froyorex4856
    @froyorex4856 5 років тому +1

    This is exactly what I wanted .
    (But for Rockets following a player)
    Please update this.

    • @Kidscancode
      @Kidscancode  5 років тому +1

      I'm pretty sure I already replied to you in another thread. I have seeking missiles in my topdown tank demo: ua-cam.com/video/KAUP4nlJyz0/v-deo.html

  • @molekula1540
    @molekula1540 4 роки тому

    can someone tell me what is offset

    • @mrpedrobraga
      @mrpedrobraga 4 роки тому

      It's the point where the force is applied. If you punch a cube at its edge, it might rotate.

  • @Draxacon
    @Draxacon 7 років тому

    Thank you so much for all of your programming help. You are excellent at explaining things, and have been a great help for me learning to make stuff. thanks :)

    • @anuyamohalkar
      @anuyamohalkar 4 роки тому

      Nkfjfjjfjjjdjhehrujjsjjjjekjajkjehhgjwksghjjjnjsankjkjjjjjkmmjjjsjejejjdjdkkdskskkddkkdjshjjj jjjjjkkjjjjjjhhjjjjkjjhhhjdbjmhjnjddjjnzjzxjjzjsiizskzkkdjkzkjjxjxmkdkdjdjdjkfkcjjdkkkfjfjfiffikkfmkmfkfkofogkcncckjfjfjjcjfvkvkfbnfovkkffjhfjfjckcifjfjfjjdikdbdxjhdjfndhjhxhdbbdjxjjdjdkedjjnxjjjjixkkxjxjcjdhhcjxmxk m’mxj ugh gbxnbxbhbdhhxhgssxhgggxgghg G fdgxgffxgxggzhgsjegsdbjdjdjfy kvjhihnjcjxjjfjzjdjdkxndkxmmxmfmcjfjfjfkxjfndndmcnhcydh th rjigtiitirjkrkdk he ifhjwbdjdjj&;!,!),),&$,$$,’fhbx

  • @IndieLibre
    @IndieLibre 7 років тому +1

    Muchas gracias por tus vídeos!

  • @leeramer171
    @leeramer171 4 роки тому +1

    Hmmm, this does not work properly at all in ver 3.2.1. The screensize variable needs screensize = Vector2() otherwise it will give a get null error. When applying the func _integrate_forces the ship always remains half offscreen at the top left and when applying thrust, it moves very slow and then tries to move backwards, very strange. It works fine (except for off-screen teleport).
    If it works for you, would you mind adding the code that works? Love your tutorials by the way, One of the best so far in the Godot World.

    • @leeramer171
      @leeramer171 4 роки тому

      Hmmm, looks like the screensize = get_viewport().get_visible_rect().size was the issue. When I pit the vectors in manually then there is no issue and it works

    • @user-lq1jn5nd4d
      @user-lq1jn5nd4d 4 роки тому

      @@leeramer171 thank u

    • @leeramer171
      @leeramer171 4 роки тому

      @@user-lq1jn5nd4d You are welcome

  • @WouterB21
    @WouterB21 7 років тому

    So i'm currently making a game (Wich is possibly due to your tutorials, thanks!), but in Godot 3.0 they removed the opacity option in sprites. And i want a sprite to slowly fade in. How do i do this now? I've looked all over the internet but nothing about it in Godot 3.0

    • @Kidscancode
      @Kidscancode  7 років тому +1

      In 3.0, opacity was removed because it's redundant with the "modulate" property's alpha value. To change a sprite's opacity to 50% for example, you would do
      $Sprite.modulate.a = 0.5

    • @WouterB21
      @WouterB21 7 років тому

      Ah I see, thank you! But what's the 'a' for at the end of '$Sprite.modulate.a'?

    • @Kidscancode
      @Kidscancode  7 років тому +1

      Follow the docs:
      - Sprite inherits CanvasItem (docs.godotengine.org/en/latest/classes/class_canvasitem.html)
      - The CanvasItem.modulate property is of type Color (docs.godotengine.org/en/latest/classes/class_color.html)
      - Color has properties r, g, b, and a (alpha) In RGBA color, the "A" represents the transparency value from 0 (fully transparent) to 1 (fully opaque)

    • @WouterB21
      @WouterB21 7 років тому

      aha thank you, i understand now!

  • @geraldoamaral3000
    @geraldoamaral3000 7 років тому +1

    Excellent tutorial. Thanks a lot!

  • @TheTattorack
    @TheTattorack 3 роки тому

    This has been super helpful, thank you! Playing around with the rigid bodies is going to be fun.
    But there's a thing I'd like to know. So I'm making a 3D platformer with attack combos.
    It's fine that my character can push around a box or a ball by simply colliding with it, but how do I apply a directional force to the physics object when I punch or kick the object?

  • @willplaya9972
    @willplaya9972 7 років тому +1

    Hey, would you please consider making further python tutorials perhaps on the basics and even more pygame tutorials? I would really love more content on python. Something specifically that I would like to learn more about is classes in python if that would be possible. Your videos are honestly the best resource I have found on UA-cam, and the structure of your videos really suit my style of learning, and I would really love more content on python to further extend my knowledge :) Thank you!! :D

    • @Kidscancode
      @Kidscancode  7 років тому

      I'm not against it, but right now I'm very busy with Godot-related material because of the 3.0 release. After that, we'll have to see what happens. In general, I'm sort of frustrated with the state of Pygame. I love using it from way back, but it's so out-of-date and showing its age, especially compared to frameworks like Love2D.
      In the meantime, if you're looking for more about the basics, this is my favorite Python book: openbookproject.net/thinkcs/python/english3e/ and includes a good chapter on objects and classes.

    • @willplaya9972
      @willplaya9972 7 років тому

      What an amazing resource, thank you soo much for showing me this.
      I am currently completing your platformer pygame series and I also want to end up completing the tile based game series. I really enjoy completing projects which is why I like your pygame series. Do you recommend for me to continue applying my basics with projects and develop with them or go back to the theory side of things (online courses, books, etc
      I also really enjoy object orientated programming, which is probably why I really enjoy game development, however I understand that C++ or Java may be better for stuff like game dev. (correct me if I'm wrong!)
      Should I continue with python or venture into another language such as C++ or Java if I want to continue game development. I've been looking around at Unity, (which uses C#?) as well. (I guess I could learn both as well!)
      Right now I'm 15 and coding is a passion for me, and my ultimate goal is to study and pursue a career in software engineering. I really want to make sure that I know what I should (and shouldn't) be doing. I think I'm coming off as a little paranoid right now but I hope that's okay :)

  • @jaysanprogramming6818
    @jaysanprogramming6818 6 років тому

    So, the main difference between _physics_process and _integrate_forces is that the latter allows non physics properties modifications to the RigidBody2D. Am I correct? Does it come with drawbacks? Why not use _integrate_forces by default for all physics management then?
    The documentation is a nightmare to understand anything and I'm very happy that people like you are making tutorials about Godot. I don't know what superpowers you have to manage to make sense of the documentation. This is beyond my understanding...

    • @Kidscancode
      @Kidscancode  6 років тому

      _integrate_forces is specifically for rigid bodies, when you need to do something custom to the physics. _physics_process is for when you need code on any node that runs synchronized to the physics timestep.
      As for the documentation, are you talking about the class reference? Because that's intended for developers - it's a reference, to give you the information you need when you know what you're doing, but just need to look up a function or definition. I'm just guessing here, but if you're new to programming, that's why it seems not to make sense to you (yet). Educational documentation is very different, and can be found under the "Getting Started" and "Tutorials" sections.

    • @jaysanprogramming6818
      @jaysanprogramming6818 6 років тому

      @@Kidscancode Well, actually I was specifically talking about the Getting started and Tutorials sections. The API documentation is really good but to get the most of it, one must understand how the general engine works. And that's exactly what the educational part is lacking: understandable content. It explains the inner workings of each part of the engine without any explanation nor examples on how to use it. It's more a design choices list than a helpful "getting started" part. Over everything else, I want to learn how to use the engine then have some explanations on why use that technique rather than another (just like this video does). I cannot make sense of anything in the documentation. Each time I read a section, it's too technical and useless. It's not beginner friendly. Even the example projet is only a follow through tutorial without clear explanations of techniques that I can transfer to a personal project. I do understand that a first project can be a features show to get an overall image of the engine but it should be followed by a thorough analysis of the project done in order to understand it fully. That's why I really enjoyed your Godot 101 series: it's really detailed and helped me get a solid grasp of the engine. Before that, I tried many times to make sense of the documentation (nearly two years now) and couldn't even make a simple Pong. With only the first five videos of your 101 series, I could at last do it. I learned some small but really useful tips (like hovering over a property in the Inspector to know the exact name of the property in GDscript) from many sources (mostly youtube channels and discord servers) but none come from the official documentation.

  • @BastiaanOlij
    @BastiaanOlij 7 років тому

    Love the tutorial. Do you have any suggestions to change the physics behaviour? I need an object to basically behave like a kinematic object when under direct control of the user, and as a rigid body when the user releases control

    • @Kidscancode
      @Kidscancode  7 років тому

      That's a good question. My first thought would be to toggle the mode property from MODE_RIGID to MODE_KINEMATIC. The tricky part will be in handling the transition smoothly. Sounds like a fun project to tinker with.

    • @BastiaanOlij
      @BastiaanOlij 7 років тому

      KidsCanCode i’ll let you know how a manage when i tackle it:) on holidays atm:)

  • @Oxtorayk
    @Oxtorayk 7 років тому +1

    Thank you!

  • @tobuslieven
    @tobuslieven 2 роки тому

    I wish I'd got this video before I spent a week trying to change an object's physics inside _physics_process(). Docs and tutorials should point users to _integrate_forces() by default.

  • @joaomarinho2602
    @joaomarinho2602 5 років тому

    This tutorial helped me a lot. Thank you!

  • @costiemonster
    @costiemonster 4 роки тому

    Anyone know how to increase the min and max speed of the creeps as time goes on so that the challenge gradually increases. This is my failed attempt, please don't judge me too harshly ;) :
    func speed_increase() -> void:
    if score > 20:
    $Mob/MAX_SPEED = $Mob/MAX_SPEED + 100 and $Mob/MIN_SPEED = $Mob/MIN_SPEED + 10

    • @Kidscancode
      @Kidscancode  4 роки тому

      Just do it when you spawn the mobs. The main scene sets the speed of them when they are instanced. Add a time-related value to that.
      Why is this question posted on the RigidBody video?

    • @costiemonster
      @costiemonster 4 роки тому

      @@Kidscancode Thanks a lot I came to that conclusion, however, I am quite sure the code could be neater:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED, mob.MAX_SPEED), 0).rotated(direction))
      if score > 15:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+100, mob.MAX_SPEED+200), 0).rotated(direction))
      elif score > 30:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+200, mob.MAX_SPEED+400), 0).rotated(direction))
      elif score > 45:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+300, mob.MAX_SPEED+600), 0).rotated(direction))
      elif score > 60:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+300, mob.MAX_SPEED+600), 100).rotated(direction))
      elif score > 75:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+500, mob.MAX_SPEED+1000), 200).rotated(direction))
      elif score > 90:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+600, mob.MAX_SPEED+1200), 300).rotated(direction))
      elif score > 105:
      mob.set_linear_velocity(Vector2(rand_range(mob.MIN_SPEED+700, mob.MAX_SPEED+1400), 400).rotated(direction))
      else:
      null
      Thank you so much for all your lessons :)

  •  7 років тому

    thanks for this tutorial. I just finished the asteroid tutorial (15 parts). Did you put the code into github for this video ?

    • @Kidscancode
      @Kidscancode  7 років тому

      Hmm, I didn't because it was such a small project. I can put it up as soon as I get a chance.

    •  7 років тому

      I did copy the code manually it's not the long, but for someone that just want to play with it or search code in github it's fun to have code . thanks again for the video. I had a good time watching them all week

  • @yukmsacierzorro
    @yukmsacierzorro 4 роки тому

    I really just made a game about a rocket dodging orbiting and falling asteroids, using just kinematic bodies... How the hell did I forget to use rigid bodies hahaha?!
    Guess it's just me being a control-freak.

  • @henndickenson4152
    @henndickenson4152 3 роки тому

    You just made the base game for Angry birds

  • @hemnqadr568
    @hemnqadr568 3 роки тому

    really useful

  • @rustyelectron
    @rustyelectron 3 роки тому

    Thanks for the explanation, I now understand physics in godot much better.

  • @ratatouillepg3135
    @ratatouillepg3135 2 роки тому

    The first step, HOW DO I EVEN FIND THE RIGID BODY

  • @IronBrandon22
    @IronBrandon22 5 років тому +1

    I keep thinking he's saying Twerk

  • @lucasvaldezdimaria5025
    @lucasvaldezdimaria5025 3 роки тому

    my godot not have rigid bodies :v

  • @Pspisripoff
    @Pspisripoff 7 років тому

    ASSETS ARE HERE..... kenney.nl/assets/physics-assets
    :)