Godot 3D Rotate Direct Constant Smooth - Demo

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

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

  • @brmaddox
    @brmaddox ปีที่แล้ว +14

    For whoever's guessing, 'smooth' goes like this:
    rotation.y = lerp_angle(rotation.y, atan2(-direction.x, -direction.z), delta * SMOOTH_SPEED)

    • @travh98_
      @travh98_ 8 หลายเดือนก่อน

      You have made my day!

    • @sirbeefboxchannel358
      @sirbeefboxchannel358 7 หลายเดือนก่อน +1

      thank you!

  • @captainripley4086
    @captainripley4086 ปีที่แล้ว +1

    This is exactly what I needed! Thank you!

  • @n30hrtgdv
    @n30hrtgdv 4 ปีที่แล้ว

    That smooth one looks amazing!

  • @tuanisapps8827
    @tuanisapps8827 2 ปีที่แล้ว

    I have been struggling with this problem all day, and you gave me the perfect solution. THANK YOU!!

    • @domedin9894
      @domedin9894 ปีที่แล้ว +1

      What solution where code?

  • @emi_cpl
    @emi_cpl 4 ปีที่แล้ว +1

    This is amazing! Thanks for making the video!

    • @JohnnyRouddro
      @JohnnyRouddro  4 ปีที่แล้ว

      Thank you. happy to help 😊

  • @jakubczajkowski407
    @jakubczajkowski407 3 ปีที่แล้ว +3

    This helped me enormously on multiple projects already. Thanks, It's a really clever piece of code. However, do you know if there is a way to get rid of the stutter/vibration on "smooth" rotation when using a higher rotation speed?

    • @jaws8621
      @jaws8621 3 ปีที่แล้ว +1

      Having this issue too. You ever solve it?

    • @jakubczajkowski407
      @jakubczajkowski407 3 ปีที่แล้ว +1

      @@jaws8621 Unfortunately nope

    • @jaws8621
      @jaws8621 3 ปีที่แล้ว +2

      @@jakubczajkowski407 Damn, thanks for getting back to me regardless.

  • @jisatsu4288
    @jisatsu4288 ปีที่แล้ว

    thanks

  • @JiosX
    @JiosX 3 ปีที่แล้ว

    what if I want to rotate a faced down 2d card and I want to reveal the hidden content and want to rotate like flipping it from left to right? is that possible?

  • @lilugoart
    @lilugoart 4 ปีที่แล้ว +2

    Hi! What if i wanted my object to rotate (with the direct mode) only with 90° turns (without the upperleft, upperright, downleft and downright) ? I've been trying to mess around with the code but i can't really pull it out to work the way i want, thanks!
    edit: i am new to Godot beacause i usually used Unity engine but i'm trying to learn this engine :)

    • @JohnnyRouddro
      @JohnnyRouddro  4 ปีที่แล้ว +2

      Hello, thanks for the comment 😊 The system you're describing is called stepping. GdScript has a built in method stepify(float a, float b) which snaps the float a with b amount of steps. for 90° snaps the code would look like this (direct mode):
      rotation_degrees.y = stepify(rad2deg(atan2(-direction.x, -direction.z)), 90)
      You can apply it in smooth mode too:
      var angle = stepify(atan2(-direction.x, -direction.z), deg2rad(90))
      rotation.y = lerp_angle(rotation.y, angle, delta * SMOOTH_SPEED)

  • @alfredogodoy6854
    @alfredogodoy6854 ปีที่แล้ว

    THX!