I coded a 2D player controller in 2 LINES! (Godot 4)

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024
  • #gamedev #challenge #godot
    🚀 Support me on Patreon: / minapecheux
    In Godot 4, it's easy to make a player controller script, both for 2D and 3D. But... how much could we actually shrink it down? Can we implement this in just 2 lines of code? (Spoiler: yup!)
    Time for a little Godot/GDScript game dev challenge!
    ================
    Music by: Bensound.com/free-music-for-videos
    License code: 2QYXGHHKBXHYVPZJ

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

  • @evilpollination1916
    @evilpollination1916 3 หลายเดือนก่อน +2

    Love how you focus on concept and not just raw code.

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

      Thanks, I'm glad you liked the approach! :)

  • @joseph.m8456
    @joseph.m8456 3 หลายเดือนก่อน +3

    Loved it you're sooo talented ❤❤🎉😌😌

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

      Haha thanks :)

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

    Loved the video. Very simple. I was wondering where you got the assets from, since I can't find them at Kenney's or Lousberg's.

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

      Thanks, glad you liked it! I actually made those myself :) (if you're curious, those were part of my latest "mini-solo-jam" project which I detailed in this devlog video: th-cam.com/video/NDgQlPYqvak/w-d-xo.html)
      (I just realised I forgot to remove the asset links from the desc, those were copied from another video - thanks for helping me see it!)
      Cheers!

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

      ​@@minapecheux I actually saw that video after this one! Always have been a fan of Paper Cutout style sprites, so I loved how it looked. Good job!

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

      @@softbread1728 Glad you liked the other video, thanks a lot for your kind comment :)

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

    I just started learning Godot and programming. And I have a question. Will shortening the code this way improve performance?

    • @minapecheux
      @minapecheux  3 หลายเดือนก่อน +2

      Heya! Honestly - not in all generality, but here I think there shouldn't be any impact ;)
      I'm mostly removing spaces or new lines, and the only real change in terms of logic is calling move_and_collide() instead of move_and_slide(). And if you look at the Godot engine's open code on Github (github.com/godotengine/godot/blob/master/scene/2d/physics/character_body_2d.cpp#L112), you'll notice that the move_and_slide() logic in fact calls move_and_collide()! So we're not changing a lot here, we're even simplifying things a little.
      (Plus, since we're not declaring a variable for the input direction computation anymore, we're saving a little bit of memory as well.)
      However, keep in mind that this is just true in this case. In other cases, you might "shorten the code" in less efficient ways :)
      Hope it helps,
      cheers!

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

    t'es francaise? chouette video!

    • @minapecheux
      @minapecheux  3 หลายเดือนก่อน +2

      Yup, tout à fait :) Merci beaucoup, ravie que ça t'ait plu !!

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

    Nice!

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

    We can make the entire game in a single unreadable line that will make no difference to the compiler because we are the chad 😎

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

      That challenge was definitely not best practices but it works 😅

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

    Can you make a character select tutorial in godot

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

      I like the idea! You're thinking more of a character class/hero selection screen, or a rts-like unit selection? 🤔
      Thanks for the suggestion anyways!
      Cheers :)

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

    How to have the input method player controller for creating a mobile game? May I request a tutorial from you?

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

      Heya! That's definitely a great idea! I'll admit I'm a bit less versed in mobile games so I don't think of topics related to this platform, but it's absolutely worth exploring - I'll add it to my to-do list, thanks a lot for the suggestion :)

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

    E F F I C I E N C Y😂

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

    Strange accent + speaking fast = not a very understandable result.

    • @minapecheux
      @minapecheux  3 หลายเดือนก่อน +2

      Heya - I'm sorry you couldn't enjoy the video. If you want, there are English/French subtitles on this one.
      Hope it helps :)
      Cheers!