Tweens in Godot 4 Are Amazing!

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 38

  • @Chaff_Games
    @Chaff_Games  9 месяцев назад

    To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/ChaffGames . The first 200 of you will get 20% off Brilliant’s annual premium subscription.

  • @wolcamophone4783
    @wolcamophone4783 8 месяцев назад +8

    That bit at the end where you show how to use tweens to make smooth camera following is a golden drop of game juice. Putting it in any game that emphasizes movement flow makes any project just feel more professional and fun.

  • @codestuff2553
    @codestuff2553 9 месяцев назад +12

    For the moving platform you should be able to use an AnimatableBody3D instead of character body - seems like you were trying to find something closer to staticbody

    • @Chaff_Games
      @Chaff_Games  9 месяцев назад +3

      Oh cool I will give that a try

  • @adenashiscave
    @adenashiscave 9 месяцев назад +4

    Oh, wow! That camera zoom and rotation is great! I've been thinking about looking further into tweens because they seem so useful. Great video!!

  • @infintygamers00
    @infintygamers00 9 месяцев назад +1

    My team and I were just leaning into this subject! How wonderful that the next day you upload this video. Thank you and keep up the good work :D !

  • @futursoup9007
    @futursoup9007 19 дней назад

    Your tutorials are fantastic, mate 🦖 THANKS

  • @tjspeirs75
    @tjspeirs75 9 месяцев назад +2

    oh my god i need the camera section of this! thank you!!

  • @TheBugB
    @TheBugB 9 месяцев назад +23

    Don’t make me tween my mouse cursor to the like button! Whatever that means!

    • @Jx_-
      @Jx_- 5 месяцев назад

      You can tween a mouse cursor to the like button, but you can't make it click (without the proper code of course)

  • @guillermoprados7631
    @guillermoprados7631 9 месяцев назад +2

    thanks man! really useful tuto.. I'm already using tweens a lot.. but you exposed a lot of details I didnt know :)

  • @RexSacriticulus
    @RexSacriticulus 8 месяцев назад +2

    i have opted to use cubic bezier instead of the built-in easing equations in my custom build.

  • @ydkim8755
    @ydkim8755 4 дня назад

    practical and great thank you

  • @nicolaslanzoni9385
    @nicolaslanzoni9385 5 месяцев назад +1

    why all godot developers refuse to use the godot naming convention ?
    PascalCase for class names, singletons and constants . snake_case for everything else .
    What even is "Camera_Tween" ? Snake_Pascal_Case?

    • @Chaff_Games
      @Chaff_Games  5 месяцев назад

      It’s just letters bro, they can’t hurt you.

  • @enjoful
    @enjoful 5 месяцев назад +1

    so in the camera interpolation code, you are making a new tween object every frame basically?

    • @Chaff_Games
      @Chaff_Games  5 месяцев назад

      Yes. You’ll find people either indifferent or against this practice. From what I’ve researched it doesn’t seem to affect performance and it is not stated anywhere in the documentation that you shouldn’t do it. But of course you can achieve the exact same result with a lerp function.

  • @jeffvenancius
    @jeffvenancius 9 месяцев назад +2

    One thing I couldn't make it to work was for global position

    • @gablanwheel3895
      @gablanwheel3895 9 месяцев назад +2

      I think global position is a derived value so that’s why it doesn’t work. Instead you could get the global position of both your start and end position then calculate the relative distance between them. Then you can tween your position to the current position + the relative distance.

  • @Nickajaster
    @Nickajaster 9 месяцев назад +1

    Nice video

  • @LiveGameDriveChannel
    @LiveGameDriveChannel 9 месяцев назад +1

    Good video!

  • @VRNocturne
    @VRNocturne 8 месяцев назад +1

    Would this work for character walk cycles?
    Like I make a sprite and draw in a couple key frames - could I use this to get the in-between frames generated in code?

    • @Chaff_Games
      @Chaff_Games  8 месяцев назад +1

      You could use a tween to the frame of a sprite2d easily. But it won't interpolate what doesn't exist. For example you could use this to switch between two frames.
      var tween = get_tree().create_tween()
      tween.tween_method(Sprite.set_frame,0,5,1)
      And this will cycle between frames 1-5 over 1 second.
      thanks,

    • @VRNocturne
      @VRNocturne 8 месяцев назад

      @@Chaff_Games Awesome - that sounds great. Thanks for the response :)

  • @rozaco_games
    @rozaco_games 8 месяцев назад +1

    Hey chaff would you help me. If we use navigation enemy automatically finds us but I don't want it.i want that when my player enters enemy's area enemy should follow and hit the player

    • @Chaff_Games
      @Chaff_Games  8 месяцев назад

      Hey there, i don’t really understand what you’re asking about but jump on the discord and we can talk there

  • @longlivethesecondplaceice2736
    @longlivethesecondplaceice2736 2 месяца назад

    Hi can you guide me for what am sourcing for let me explen.
    I really want to make a vector2d rig
    Game with procedural small animetion just like you said in the vidoe with tweet.
    Am useing blender to make the 2d meshes and import them into godot it works really well but I want line art on my mesh just like any 2d vector software that uses 2d vectors to form shape it also has strokes for lineart and I need thst in my rigs.
    I can't import strokes in godot so I have to make them in godot with wail animating foes strokes but the are no guide or sources telling me how I can make this possible.
    My English is messy but I hope you can still help me I really want to make this projact real.

  • @comfyzenny
    @comfyzenny 9 месяцев назад +3

    i've said it before but ily

  • @michavk
    @michavk 9 месяцев назад +1

    You use a Tween when you want a multi frame transition *without relying on _process*. If do it in _process, you might as well use lerp! 😂

    • @Chaff_Games
      @Chaff_Games  9 месяцев назад

      Yep, lerp is totally fine. But this video is about teeens.

    • @lukabrasi001
      @lukabrasi001 8 месяцев назад +1

      @@Chaff_Games he means that you'd use tweens if you didn't want to depend on _process functions. doing tweens in _processes defeat the purpose

    • @Chaff_Games
      @Chaff_Games  8 месяцев назад

      I understand what he means. And I agree to a certain extent. I even briefly mention that in the video before doing the camera that way. I haven’t seen anything in the documentation that specifically forbids though.

  • @tmilker
    @tmilker 9 месяцев назад +2

    I don't think using a tween for the interpolated camera is a good idea, you're destroying and creating a new Tween every frame which is going to create a lot of memory fragmentation. It would be heaps(hah, get it? #programmerpun) better to do the rest of the math and use look_at.

    • @Chaff_Games
      @Chaff_Games  9 месяцев назад +2

      It's good question. I actually don't know how Godot handles the tweens under the hood and if this is bad at a lower level. Of course it's only an example you don't have to do it this way, but nothing else will get the smooth movement.

    • @tmilker
      @tmilker 9 месяцев назад +4

      @@Chaff_Games You can get smooth movement by using interpolate_with() where the weight parameter is just your sine easing function, 1 - Math.cos((x * Math.PI) / 2). You just have to reset x whenever the target position changes and increment it by delta otherwise(until you get to 1, for a 1 second ease, divide 1 by your ease time to slow it down/speed it up). Right now, what you're doing is creating a tween, using the tween to move very slightly to "catch up" with the target and then throwing the tween away and creating a new one on the next frame. You only get the smooth movement when the target has stopped moving which is when your sine ease takes over. Maybe Godot pools Tweens so it's not so harsh on memory but I haven't found anything in the docs to suggest it.