How to Detect Gestures and Swipes in Godot (tutorial)

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 59

  • @TyperMarlinGames
    @TyperMarlinGames 2 роки тому +13

    Awesome!
    Just one tip if you're stuck, you need to tick "emulate mouse from touch" in the settings in order for this to work

  • @bruno963852
    @bruno963852 6 років тому +48

    Very nice! But i would add a little step to detect and exclude very short swipes, just adding a variable called min_distance and checking the distance of the swipe to determine if is bigger than the threshold.

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

      Good Idea!

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

      Guys, is there a way to have smooth transition between slides, not this instant one?

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

      @@RTSFan1337 Do you know how to make slides shift smoothly, not instantly?

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

      @@elektroskeptic481 You will have to work with the animation player there. I'm necroing this just to post an answer here case anyone else has this doubt. A tut on this can be: ua-cam.com/video/x8wgVNN9FsI/v-deo.html. That's just an example, you can use it for fade effects on scene transitions, etc, etc.

  • @the-birbo
    @the-birbo 2 роки тому +5

    I think it might be important to use the "emulate touch from mouse", and also I changed the code so that if the x and y directions are the same, it's not gonna just say i swiped vertically, but rather emit a signal for a click

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

      Can you show me that code? I am trying to implement taping in my game and am having a bit of trouble

    • @the-birbo
      @the-birbo 2 роки тому +1

      @@Silve4 Sure, but first try to work it out with what I've said. If the x direction has the same value as the y direction, emit a custom signal.
      If you're not sure what most of that means, you should learn about if statements and custom signals. If you still need help I'll post my code. try to push yourself 😊

  • @RickoDeSea
    @RickoDeSea 5 років тому +8

    I love your voice. It makes enjoying the tutorials 10x more.

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

      Thanks for the kind comment 🙂

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

      I think he has a Brazilian accent, because I'm from Brazil too

  • @Watermster
    @Watermster Рік тому +1

    how would be the "export" code line equivalent to Godot 4? the syntax has changed and I can't get it. Tryed the @export but i get an error "Annotation @export requires at most 0 arguments, but 3 were given.". The code: @export (float, 1.0, 1.5) var MAX_DIAGONAL_SLOPE = 1.3

  • @kirilvangelovski1255
    @kirilvangelovski1255 4 роки тому +2

    Brilliant! Just what I needed and it wasn't going to be easy to figure out.

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

    Guilherme??? different pace, this is much better (for me) than when you are rushing, thank you nice tutorial!!!

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

    THANK YOU SO MUCH! THIS WAS SO HELPFUL!

  • @rafaelgarcia1435
    @rafaelgarcia1435 4 роки тому +5

    And if I want to draw a Line2D using the start and end of the swipe?

  •  6 років тому +4

    Can something like this be done to control the panning of the camera when the user is dragging or is there a better way to do it?

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

      There is, I do it like that:
      pastebin.com/tw00TYEi

  • @glowblock64
    @glowblock64 3 роки тому +1

    "This is a bit of text
    And here's some more
    Coloring is going to be a pain in the butt"
    So understandable :P

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

    Hello I realize I’m not sure I understand the math behind the slope and the angle (especially the math vocabulary since english is not my native langage). So I was wondering if anyone could link some ressource about it. Would be really appreciated.
    To add a little bit of context, I tried to readapt the code to be able to handle vertical swipe aswell as horizontal swipe but it wont detect swipe going up but the others directions work. I only changed the maximum slope to 1.5 and the timer to 1 second, nothing else.

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

    Thanks a lot!

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

    Can you please make a video about how to make UI elements follow the player within the camera? When my player moves, the UI elements don't follow him. I wanted to know if there is a smart way to do this with Nodes. Rather than updating the position of the UI in the process function.

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

      canvas layer
      you are making things worse.

  • @hs-studio
    @hs-studio 3 роки тому

    Guilherme vc é br, vc não me engana 🤣🤣

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

    WOOW! thanks a lot

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

    it's what you need. I wand adaptive this for swipe of mouse, for multi platform game.

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

    bro i am messing too much... in your channel there was a playlist that how can we make our first platform 2d game in godot but the problem is how can i do gestures in that game pls help me.....

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

    Thanks and n8ce tutorial.
    Pls make how to know touch position in screen to shot to that position.

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

      To know where teh Player touched, you just use "event.position" in your _input function. If you want to know the part how to translate the touch position to a position in your game world, here you go:
      pastebin.com/uVgmzKFU

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

      If its a 3D game you can shoot a raycast from under your cursor

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

    And then, how can i detect the swipe , i tried to test with a print but i cant, pls anyone can help me??

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

      Connect the signal

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

    Nice, now add it as a feature in godot

  • @justdavid6678
    @justdavid6678 Рік тому

    please make an updated tutorial

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

    Which script is used : gdscript or c#

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

      Pretty sure it's gdscript. Not sure if you still need this answer.

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

    hy eveyone, if i have a button pause, how i know it just press button, i don't wana Swipes now

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

    Thank you very much for getting me started with the Gesture Controls implementation for my game.
    But when things became clear, I completely branched off from the tutorial (stopped watching it)
    because copying the tutorial as-is for my much more specialized use-case
    (where the gesture detection doesn't need to be nearly as precise)
    would've been Very Stupid because there would've been a lot of stuff in my code that I don't actually need.

  • @libanjustinelowied.1560
    @libanjustinelowied.1560 4 роки тому

    Can u please make a tutorial about tilt control in android

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

    BR maninho? Nice tutorial!

  • @Zen-rw2fz
    @Zen-rw2fz 3 роки тому

    I can't get the input event to trigger at all. no matter how muhc I touch nothin happens

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

    How to connect it

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

      Either with code:
      - In the Script of the SwipeDetector paste this:
      *func _ready():*
      *$Timer.connect("timeout", self, "_on_Timer_timeout")*
      Or Graphically:
      - Select the Timer
      - Click on the "Node" tab next to "Inspector"
      - Click on "timeout()"
      - Click on "Connect"
      - Click on "Connect" again

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

      @@bittim Still not working.

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

    Thanks bro

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

      You're welcome!

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

    I cant make this project work under godot 3.5.2

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

    I would like a tutorial on how to detect continuous long touch, for like a hypercasual game. Also if anyone knows where I can get free hypercasual game templates, I will be most grateful.

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

    enable on your pc emualte touch from mouse

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

    You explain in rigid stiff fierce softness. I didn't like it. LOVE IT

  •  6 років тому +4

    I found that the mic automatically muting (voice activated) is a bit irritating. I would rather hear some background noise than total silence when you're not saying anything.
    About the content, it looks very useful! Thanks!

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

    What a version of Godot it is?

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

    No entendí nada

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

    so how to use it? this is not a noob friendly tutorial hmm :((

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

      I need it to :((((