How to Improve Your Camera for Platformers in Godot 3.1

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

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

  • @GameEndeavor
    @GameEndeavor  5 ปีที่แล้ว +27

    Howdy, everyone! It’s been a while, but I’m going to be doing tutorials again! I will say, I sure have missed you guys. Enjoy the video. Let me know if there’s anything you would like to see, and y'all take it easy.

  • @androidgameplays4every13
    @androidgameplays4every13 5 ปีที่แล้ว +7

    Nice to see you back, you're one of my top 5 Godot tutorial makers, keep up the good work!

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

      what are the other 4?

  • @drakibble2199
    @drakibble2199 5 ปีที่แล้ว +7

    Hey, welcome back! I've missed your tutorials, and you explain things very well. Thank you for your hard work!

    • @GameEndeavor
      @GameEndeavor  5 ปีที่แล้ว

      Thank you! I'm glad they're useful. :)

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

    Your videos are the definition of quality content. I'm so glad I found out about your channel!

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

      Such kind words, thank you! Glad you're enjoying the content.

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

    I can't thank you enough, your code worked perfectly!! I was ready to see godot crashing some 10 times, but it worked right in the first time! And I must say, after searching for this kind of camera for days, you are the only one teaching look-ahead camera for godot in the whole internet! I'll put you in the credits of the game!

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

      lol, yeah? I figured someone else would've made a video on it by now. xD Glad you found it useful. :)

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

    I can't believe how well this still works in 3.4. No issues, thanks a ton!

  • @gingerageousgames613
    @gingerageousgames613 5 ปีที่แล้ว +4

    Love that you are back.

    • @GameEndeavor
      @GameEndeavor  5 ปีที่แล้ว

      Thank you! I'm excited to be back. I missed this.

  • @decrodedart2688
    @decrodedart2688 5 ปีที่แล้ว +2

    Welcome back.
    Great vid as always.

  • @ashlin112
    @ashlin112 5 ปีที่แล้ว +8

    Glad to see you’re back!! I was wondering if you could cover wall-jumping and/or moving platforms in 3.1? I can never find anything that works

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

      Thank you! I plan on covering both of those in the near future actually. Moving platforms probably within a couple weeks, wall-jumping is a little more complex and will need a bit of setup first, but expect that one relatively soon.

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

      Awesome! Can’t wait to see more videos!! :D

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

    Just found your channel last night. Thanks for the tutorials!

    • @GameEndeavor
      @GameEndeavor  5 ปีที่แล้ว

      Thank you for watching them. :) I hope they're useful to you.

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

    I accidentally wrote "if facing != 0' and was wondering why it wasnt working XD

  • @jettt10
    @jettt10 10 หลายเดือนก่อน +6

    For Godot 4 user's
    extends Camera2D
    const LOOK_AHEAD_FACTOR = 0.08
    const SHIFT_DURATION = 1
    @onready var prev_cam_pos = get_screen_center_position()
    var facing = 0
    var tween : Tween
    func _process(delta):
    check_facing()
    prev_cam_pos = get_screen_center_position()
    func check_facing():
    var new_facing = sign(get_screen_center_position().x - prev_cam_pos.x)
    if new_facing != 0 && facing != new_facing:
    facing = new_facing
    var target_offset = get_viewport_rect().size.x * LOOK_AHEAD_FACTOR * facing
    position.x = target_offset
    tween = create_tween()
    tween.tween_property(self, "position:x", target_offset, SHIFT_DURATION).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
    func _on_player_grounded_updated(is_grounded):
    drag_vertical_enabled = !is_grounded

    • @叢雲-r3r
      @叢雲-r3r 9 หลายเดือนก่อน +1

      I love you, thank you so much.
      The only thing you need to change is to remove the position.x = target_offset line, it conflicts with the tween

    • @alexandrelegrand7833
      @alexandrelegrand7833 8 หลายเดือนก่อน +1

      Thank you to all of you ❤
      But About the node tween?

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

    Now my camera is buttery smooth + smart

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

    THIS!!!! OH MY GOD! THIS!!!!!

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

    tysm bro, great video that saved me lots of time in figuring this out on my own!

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

    Thank you so much! This was super helpful.

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

    I couldn't use these methods exactly in my 3D game since 3D cameras don't have these advanced settings like Drag Margins and Limits built-in.
    But this gave me the opportunity to code my own simple camera behavior that's fit exactly for my game.
    Before, the camera was a child of the player, which resulted in the primitive bahavior of the player being Always at the dead-center of the screen. This was good enough for the first prototypes but no longer fit for the current version.
    Now, the camera is no longer a player child, so that I could code exactly How the camera follows the player, with nuaunces like only changing the Y position when the player is on a floor or a wall, or always looking slightly ahead of the player.
    I haven't made my version of drag margins and limits yet, because I'll only do it if the lack of them becomes an issue. In game development, you want to work smart by only doing what is necessary for your game.

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

    Thankyou.Great tutorial.🤩

  • @spkingR
    @spkingR 5 ปีที่แล้ว

    Very nice video tutorial again!

  • @kugerily
    @kugerily 5 ปีที่แล้ว +2

    first minute of the tutorial Im just gotta say. I never seen anyone make a tutorial like a sergeant. I felt like a cadet here but nice tutorial nonetheless. I really am bothered by default camera controls where the camera is centered on player while hiding terrain they about to land and make it hard to land a jump safely. this is a really nice godot bootcamp sergeant

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

      It's a shame, I wish more tutorial makers took a similar approach for when I watch them. I mostly just want information as fast as you can cram it into my ears and eyeballs. ;) But on the otherhand, I have my unique selling point.

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

    Many thanks!!!

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

    Loving all of your tutorials, you do a really great job! Having a small issue though, when my character is moving I am having a bit of a distortion effect happening. It believe it is the inner box of the camera, changing the look of my tile map by a few pixels. So if I stand near a floating platform for example it will have a like visual break in it half way where part of the pixels no longer line up.

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

      Thank you! :) The first thing that comes to mind is do you have pixel snap enabled via Project Settings?

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

      @@GameEndeavor I am not, I just tried that and it doesn't fix the issue but it does make it so it happens in a more snapping motion.
      I am sure I am doing a bad job at describing it, basically if I stand still I can see the edges of the camera in game, not like as the actual blue ui line you see in the editor but just like an invisible line that is offsetting my pixels at the edge of the camera by like 1 or so. So then as I move the tiles looks off.

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

      @@Remirlis Odd. I've never noticed this, so I'm not sure what would help. I would suggest asking in Godot's Discord server if you haven't already, perhaps with a gif that demonstrates the issue.

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

      @@GameEndeavor Okay! I will do that. Thank you so much. And again thank you for taking the time to make your tutorials, they have been incredibly helpful.

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

      @@Remirlis Any time! Thank you for watching. :)

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

    I so much need something like this in 3D

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

    My camera keeps getting lost in time

  • @AlexFalkenberg
    @AlexFalkenberg 5 ปีที่แล้ว

    Welcome back!

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

    i know this video kinda old so i don't expect an answer but, you can't check if variables are = null anymore

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

      You can. What makes you think you can't? (that's not meant to sound snappy, lol. Trying to get information so I can help. :) )

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

      @@GameEndeavor well, it was just me being dumb, i tried to put the variable = null instead of variable == null

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

    make a video about the state machine and explain it for beginners

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

    but how we manage the limit border?

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

    func check_facing not working. Nothing happens

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

    The problem is that the code keeps flipping the camera from left to right and back

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

      Yes I made the camera width bigger and edited the code a little that made it better but not perfect.

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

      @@icwhy4366 is it possible for you to share your solution?

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

    I dont know if you still read the comments here, but when I try to do the last thing with the tween, I get this error message: "Tween target object has no property named: position.x.
    At: scene/animation/tween.cpp:1314"
    I'm very new to programming so I have no idea where to put the "position.x" property or what syntax to use. plz help.

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

      If it's the 2nd argument in the method then it needs to be "position:x" with a colon.

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

      @@GameEndeavor Ah thank you! Idk how I missed that colon lol

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

      @@HiveQu33n Any time. :)

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

    0:27 kkkkkkkkk

  • @patrik-2311
    @patrik-2311 4 ปีที่แล้ว

    tween hasn't got interpolate method, because the $ShiftTween doesn't exist :( Why?

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

      You have to rename the tween to ShiftTween

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

    Your code crashes Godot...also $ShiftTween doesn't exist?

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

      >>> it works, but in the moment camera move too far >>> onready var tween = $ShiftTween (write it below constans)

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

      @@jamesxxxyz8775 i did it doesnt work

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

      you have to create a tween node to your camera and give it the name ShiftTween

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

    ????

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

      Maybe it changed in Godot 3.2?

  • @notorzazel1697
    @notorzazel1697 5 ปีที่แล้ว

    That goddamn undertale reference ahha

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

      Hate to be the Bearer of bad news, but I haven't played Undertale enough to be making references to it. :)