GameMaker Studio 2: Click to Move Tutorial

Поділитися
Вставка
  • Опубліковано 30 тра 2017
  • In this tutorial code is implemented to get an object to move to where the mouse is clicked. This is a fool proof system incorporating enumerators and checks to make sure it is moving the perfect amount.
  • Навчання та стиль

КОМЕНТАРІ • 40

  • @immersemuffin8281
    @immersemuffin8281 3 місяці тому

    I've been stuck on how to mouse move. Then I found your video and I feel so much happier that I was able to move my character. thank you so much!!!

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

    great video man, really appreciate it!

  • @GurkiratSingh-rd1yt
    @GurkiratSingh-rd1yt 5 років тому +1

    Thank you very much bro! You are the best!!

  • @seniories6164
    @seniories6164 11 місяців тому +1

    thanks, you help me soo mutch!

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

    thanks, I've been trying to work out a way to have different objects move together ie. maintaining fixed relative positions when one moves like this, anyone know where I can find out about that?

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

    Thank you so much

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

    thank you SO MUCH

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

    how do we stop the vertical(up down) movement and limit only left to right?

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

    You are my hero

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

    Thank you :D

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

    thanks, man

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

    How can i make a character move based on a dice roll?

  • @baileylong9105
    @baileylong9105 6 років тому +8

    Great this works well, now is there a way to use this style of movement in grid-based style

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

      it's been 2 year since you've posted your question but here is what i've done to do what you are searching for...
      var tile_x = (mouse_x - (mouse_x % tile_size)) / tile_size;
      var tile_y = (mouse_y - (mouse_y % tile_size)) / tile_size;
      with this you can get the position [x, y] of the tile you are clicking on (tile_size need to be replaced by the size [in pixel] of your tile)
      if your not that good in mathematic you just have to understand that "%" (modulo) is used to find the rest of a division of integer (exemple : 5 % 2 = 1)

    • @TuckerTheMandolinist
      @TuckerTheMandolinist 7 місяців тому

      @@thiti5179what about slowing the object down as it reaches it's target?

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

    thanks :)

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

    I've looked over my code for an hour comparing and cant get my object to stop wiggling. did sprite size matter or any other for that matter?

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

      It should not matter.

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

      Just mess around with the numbers for the "distance_to_point" part of the code.

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

      my obj also moves to the right side of the mouse. then shakes

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

      Hmm, maybe the sprite size does matter.

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

      Hey thanks for the quick response my friend, and video! I def didn't have my sprite axis centered, still haven't figured out the shaking but I will eventually :)

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

    I’m trying the distance from point thing and it shows an error

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

    OHMYGOD

  • @chandlerraines9972
    @chandlerraines9972 7 років тому +1

    How do you glue one Sprite on top of another ? I can't figure it out

    • @Etredal
      @Etredal  7 років тому +2

      You can do something along the lines of:
      [Draw Event]
      draw_self();
      draw_sprite(spr_newSprite,x,y);
      This will draw a sprite on top of the object

    • @chandlerraines9972
      @chandlerraines9972 7 років тому

      Etredal I will try it do I write it exactly like that ? How will it know to draw it on top of the one Sprite and stay on top of it if the bottom Sprite moves , what do I do with x y im super new to coding

    • @Etredal
      @Etredal  7 років тому

      Chandler Raines x and y are the variables for where the object is. If you do draw_self() in the code first then it will be underneath another sprite that is drawn. Because that code is run first and the next sprite is drawn afterwords which will be on top!

    • @chandlerraines9972
      @chandlerraines9972 7 років тому

      Etredal will they stay together if the bottom Sprite moves ?

    • @Etredal
      @Etredal  7 років тому

      yes

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

    What should i do if it doesnt move to the point?

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

      i had the same problem in the STEP event i wrote spd = 0 ; instead of speed = 0; :S:D

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

    do uu have a github

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

      My Chess tutorial series is on github but not these older videos. You can check the descriptions for a link!