Grid Aligned Movement - GMWolf

Поділитися
Вставка
  • Опубліковано 3 сер 2024
  • In this video I demonstrate a technique to achieve the gird based movement seen in many JRPG games, tactics games, etc.
    Twitter: / gmwolftuts
    Facebook: / gmwolftuts
  • Розваги

КОМЕНТАРІ • 139

  • @hectorgarciamarin9736
    @hectorgarciamarin9736 5 років тому +4

    Ty, for all the teaching man.

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

    Very clear and helpful tutorial. 👍🏼

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

    love your video! learn a lot!

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

    This tutorial helped me a lot thanks

  • @almightymanatee3825
    @almightymanatee3825 5 років тому +4

    This is a very nice video, I have learnt a lot from it. I love the format too - finally a tutorial that isn't too slow, nor too long. Thanks a lot man, that's definitely a subscribe!

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

    Good tutorial, I have been trying to figure out this on my own but didn't manage to get that complex, you have enlighten me and given me a starting point, thanks.

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

      glad you found it useful!

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

    Hope you keep making more tutorials :D

  • @Ragnark1
    @Ragnark1 6 років тому +9

    Good and succinct tutorial. I'm glad you didn't go off on tangents. Also, having a fully edited video helps a lot!

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

      +Harbinger thanks. Glad you like the format. I think the extra work is worth it.

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

      Thanks. Next, consider some videos on 3D. I am currently almost finished with a Rubik's Cube composed of prims. It is almost functional.
      One future project I'm thinking of is to re-create the opening stage of the SNES version of Star Fox. It would very fascinating to see a re-creation run at 60fps in HD. Just a thought.

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

    holy heck dude this is great but did you speed the footage up 4x this is crazy fast

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

    Looking into crafting a system similar to the South Park games where distance from the camera changes perspective a little bit.
    I think this will help and then applying an isometric view but making the player think it’s a 2-D room..

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

    thank you for gamemaker video

  • @bassicguitar7863
    @bassicguitar7863 8 місяців тому

    Amazing video, really helped me! I was just wondering how the collision test could be adapted to stop the player moving through certain objects too? I know this may be obvious, but I've just started with gamemaker and any help would be really appreciated!

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

    Sorry, tell me how you can implement the execution of the action on the animation frame, for example, the script "blow with the sword" should be called on frame 3, before that I used an integer currentFrame, now it is fractional. Perhaps it is worthwhile to call the script not in the frame but after some time since the beginning of the animation? how best to implement it? Forced to use lerp in order to have the possibility of growth of character skills, movement speed, attack speed, and so on, without float values ​​or how not to do. Sorry do you have an e-mail?

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

    Thanks!

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

    Cool!!!!!!!!!!!! HM ... are there any more grid alignment techniques ... like in Blackthorne !! ;)

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

    This is awesome! Exactly what I was looking for. I did have a question though. If I'm next to a wall, but not facing towards it, is there a way to make the player character look towards the wall? For example, if I'm there is a wall to my left, and I'm facing down currently and press left, is there a way to make the character face left while being stationary other than the animation change?

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

      When we check if we can move into the new spot, you can add an else block and change the sprite there.

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

      @@GMWolf That worked perfectly and was very simple. Thanks a bunch!

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

    great tutorial but the collision isnt working on mine, my character gets stuck as soon as it enters the level. Im using my own assets but I cant see any reason why it shouldnt be working. Maybe something to do with collision masking?

  • @Fauntleroy.
    @Fauntleroy. 5 років тому

    This is a wonderful tutorial. I have some programming experience but am new to GameMaker Studio 2, and this was a great lesson in a variety of functions.
    Not sure if you still check these comments, but I did have one question. Some games alternate animations every other step. First step would be: idle, left foot, idle. Second step would be: idle, right foot, idle. And so forth. Rather than playing all animation frames with each step. (Final Fantasy VI is a great example.)
    If I wanted to do something similar in GMS2, would I need to create two separate sprites and alternate between them? What would be the best method in your opinion? Thanks!

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

      I would keep track of what step to perform next.
      Then use a single sprites with both animations.
      If I recall correctly GM will actually automatically remove duplicate frames and handle that for you.
      But if you like to be explicit, you could keep an array of image indices for each animation.

    • @Fauntleroy.
      @Fauntleroy. 5 років тому

      @@GMWolf Thank you for your reply! Could you illustrate for me what this index would look like? I've been studying the example of "frames = [...]" from your tutorial. But I'm not sure how to translate this into a system that alternates between two sets of animations depending on which step comes next. Thank you again.

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

      You would have two arrays like so: left_step = [...]; right_step = [...];
      Then also have a variable keep track of what step to do:
      step_type = 0; //0 for left. 1 for right.
      Then when you take a step:
      if (step_type == 0) {
      //Use left_step
      } else {
      //Use right_step
      }
      When you end a step:
      if (step_type == 0) {
      step_type = 1;
      else {
      step_type = 0;
      }

  • @ceettopotat
    @ceettopotat 5 років тому +4

    Really great tutorial ty. Its not too long nor rushed, anyone with minimum gm experience can follow allong. I learned alot from it.

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

    Hello! Very nice tutotorial. Only problem I'm having is with the collision. Going left lets you go very close to the wall, but right keeps you farther away.

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

      Is the distance more than a tile? If so it could be you are checking for collisions multiple tiles away. Otherwise it could be that your sprite origin needs adjusting.

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

      @@GMWolf Yeah it seems that it is due to the sprite origin. I might try another tile collision method.

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

      If it is just the sprite origin you just have to adjust it. Sprite origin and offset will be something to consider no matter which tile collision system you use.

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

    So I'm having an issue with trying to get the collisions to work right on my game. Instead of the wall tiles stopping movement, my player object keeps moving, and passes through the walls. I don't understand what I'm doing wrong, and need help figuring it out. My current solution is to try and set the state to idle, after I set delta time/1000000 to be multiplied by 0, rather than 2, the default speed I've chosen in for the object, however, this results in the object still moving, and they still pass through the walls, which I've made objects for.

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

      before moving the object check if he will be moving into a wall...

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

    I copied the code verbatum but the player is moving to the next tile instantly, instead of slowly moving there. Any idea what would cause that?

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

    very good, would you have a tutorial on how to make this movement, with another character following him like the phantasy star rpgs 2, 3 4, etc?

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

      You can just reuse the inputs but delayed by how ever many steps behind you want the NPC to follow

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

      @@GMWolf I tried =/ but not success ,I looked for tutorials and I can't find anything

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

    Hello! Nice tuto!
    I Have a question. I do exactly that you show. But when I try start the game, I have an error in move script: state is not defined. But works if I put the content of move script directly in key down - right event.

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

      If you are using gms2.3 or above make sure you are using the new function syntax.

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

    i typed the code the way it was shown on screen and got the following error int the move script: cannot redeclare a bullutin variable

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

    Amazing tutorial! I am trying to make a Pokémon fan game using sprites from the GBA games (Fire Red / Leaf Green). I had a few questions:
    I might just be dense, but I am not sure how I would increase the speed to match the actual Pokémon games? I didn't see an obvious variable in which to do so.
    Also, I am having some trouble lining up the animations with the sprites I have (3 frames per direction like yours, but it doesn't look right lol) any tips?

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

      Hi. Iirc this tutorial uses a time based approach, where each step takes a certain amount of time to cross.
      You can increase the movement speed by decreasing that time.
      Alternatively you can increase the time that gets accumulated in the t variable.

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

      As for the animation, it will depend on the frames you have. I think the sequence I have matches the Pokémon sequence too but I could be wrong.
      One alternative is to ditch the custom array and just do it in the sprite editor. GM will remove duplicate frames for you.

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

      If you meant lining up spacially, you will have to play around with the origin of the sprite.

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

    I cannot seem to manage to get this right, the movement always stutters unless I set walk_anim_length to be 1 second or slower.

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

    Thank you for this tutorial. I have never coded before, but following along definitely gives good experience with a number of different components of Game Maker.
    I am getting an error when I try to run the game which states that I am "trying to index a variable that is not an array". The error message tells me it's related to line 5 of the move script. I've looked, but I can't find what I've done wrong. Any idea where I might have made a mistake that would give me the error message I've described?

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

      Hi, glad you like the tutorials!
      The error you get is because somewhere, you typed something[aVariable].
      This is used to access arrays. So if "something" isn't an array, you will get an error.

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

      Thanks for the reply! I initially thought there might be a problem with the "dir" variable, but if I understand you correctly it seems the issue might be with my global.components array. I've set up the gml_pragma line as instructed, but I have to imagine something about what I've typed is incorrect.
      I'll keep looking. Worse comes to worst I'll start over and try again - would be good to get the extra practice in anyway.
      Thanks again.

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

      If you need help, I suggest heading over to the GMC at forum.yoyogames.com
      If you make a post with your code explaining the issue, there are a lot of people willing to help, myself included.

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

      Thanks. If I continue to struggle I'll definitely head there for assistance!

    • @Scotchdigital
      @Scotchdigital 6 років тому +3

      Its been a month, so you definitely probably figured this out, but for anyone else looking to figure out this problem I may have a solution since it happened to me too.
      at the ~~~global.components = []~~~ section I typed "=" after global.components for the next four lines of code.
      Mine originally;
      global.components = [];
      global.components = [directions.right] = [1, 0];
      global.components = [directions.left] = [-1, 0];
      global.components = [directions.up] = [0, -1];
      global.components = [directions.down] = [0, 1];
      the proper way;
      global.components = [];
      global.components [directions.right] = [1, 0];
      global.components [directions.right] = [1, 0];
      global.components [directions.right] = [1, 0];
      global.components [directions.right] = [1, 0];

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

    My player, who is 16 wide, will not move through a 16x16 hallway space, they get stuck :(
    Also, I am looking for the best way to add that when you press a direction, even if you are up against a wall, you will turn that direction (in the idle state)

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

      Might be worth checking the origin on your player sprites. Make sure it's the same as the origin for your wall sprites :)

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

    when i write sPlayerRight or any of the other sPlayer directions it thinks its a variable
    help pls

  • @Fauntleroy.
    @Fauntleroy. 5 років тому

    Hmmm, the collision detection piece does not seem to function for me. Has something changed since this tutorial was published? I have placed tiles on the Walls layer but still my character passes right through them.

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

      Hard to tell what the issue could be. As far as I'm aware the code should still be working fine.
      Why not head to Reddit or the GMC (forum.yoyogames.com) and post the relevant code along with the question. Plenty of people there to help.
      If you mention me on the GMC (@GMWolf) then Ill get a notification and can give it a look.

  • @The-Eric-Cartman
    @The-Eric-Cartman 6 років тому

    When creating the tilemap variable, my tilemap id is -1 according to the debugger and any time I use tilemap_get to get the tile at an x/y coord it returns -1 as well. It's in the create script for my player object. Do you know what I could be doing wrong?

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

      Maybe you have the wrong tilemap layer name. It needs to be written the same as in the room editor.

    • @The-Eric-Cartman
      @The-Eric-Cartman 6 років тому

      Thanks for the response. I double checked and the layer name matches what it shows on the room1 tab. For reference, the following is what I used, and t1 and t2 below are the variables I used to test in the debugger since I have a wall tile at 0, 0 but not at 1, 1:
      var tile_layer_walls = layer_get_id("walls")
      var tile_map_walls = layer_tilemap_get_id(tile_layer_walls)
      t1 = tilemap_get(tile_map_walls, 0, 0)
      t2 = tilemap_get(tile_map_walls, 1, 1)

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

      Hmmm, at this point I would recommend heading over to the forums (forum.yoyogames.com) and post your code there, myself and others will be able to better help you there.

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

    I really appreciate the time you spent even to make this video.
    After a week of trying other people's codes and my own combination of codes, I came across this. It has helped, but, I still can not accomplish certain things.
    I am trying to rebuild "Sabin's House" from FF6 as a learning experience. It is a pretty small area.
    In the real game, when the player moves in front of a particular plant (which covers about 15 pixels height, across two tiles), the player covers the plant. (the players 24 pixels tall). When the player goes behind that same plant, the player is covered.
    I am not sure how I can manage the collision detection to make it so you can't walk through the plant while simultaneously being capable of standing on either of the two tiles that have the plant drawn on them (you can walk in from left or right, but, not up or down) AND at the same time have the plant sprites render correctly, above or below the player...
    Do I need to set up multiple layers and collisions and activate / deactivate them as the player passes certain areas of the map? Maybe detection based on object would help instead? Before I started using your code, I noticed with place_meeting I could "accidentally" slip the player into occupied squares, while I was using an object that contained a sprite less than my grid size (like a 4x4 in a 16x16 grid), successfully blocking me from coming in from certain directions.
    ALSO
    how can I switch the walking animation every other time you command the player to walk?
    I noticed in the game, the walking animations alternate every time you let go of walk, and continue walking again. you will start with right hand, then if you let go and start again, you will start with left hand and so on.
    Hope that made sense :)
    please help, I am up till 2 in the morning every night after work, till I fall asleep on my keyboard and feel like a zombie.
    I may post on game maker forums in a bit as suggested below, but, right now I need a 15 minute break.

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

    What if i want my player to have a custom size (like 64x128) ? I tested it on my own but he just collides into the walls :(

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

      Then you will need a more complex way to check collisions.
      A good starting point is to consider the tiles the player is already occupying, and where they will end up if he moves.

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

    Hi , just wanted to know , how to add the sprint functionality , i change the walk_anim_length when sprint key is pressed , the player move fast but it make some jerk like movement. can you help me on this . thankyou

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

      It's probably because we reset the animation time to 0 for every grid step. What we should be doing is carrying over any excess when we get to the end of one step, into the beginning of the next.

  • @masonh.9605
    @masonh.9605 6 років тому +1

    So in the video, you have your walls set as tiles, what if I used objects instead?

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

      +Mason H. Not much difference: when you check for collision, use the object colision functions instead

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

      +@@GMWolf
      Can you elaborate further on this, please (allowing for collision checking with objects, that is)? I've been trying to figure out how exactly to do this, but I've been having trouble with it.
      I've tried a number of ways to get it to work, but the current potential solution I've been working with is simply adding another if statement to the Move script in-between checking the "Walls" layer and the actual code that allows the player to move that looks like this:
      if !(tilemap_get(tile_map, x_pos + dx, y_pos + dy))
      {
      if (position_empty(x_pos + dx, y_pos + dy))
      {
      x_from = x_pos;
      y_from = y_pos;
      (So on and so forth)
      The issue that I'm having is that the coordinates provided for position_empty are never actually detecting if an object's collision mask is in that spot. It works if I give it direct coordinates on or off an object in the world, though. So I'm not entirely sure what's going on with it.

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

      -Update-
      I've actually found a solution to this, although it seems as though it has the potential for bugs, so I'm working on seeing if it could cause issues with certain situations. But for now, here's what I've got so far. Sorry about the indentation as well, you can thank UA-cam for butchering that.
      (Additions to "MACRO" in bold. Note: The variables are global mostly for debugging purposes.
      gml_pragma("global", "MACRO()");
      #macro tile_width 16
      #macro tile_height 16
      *globalvar directionX;*
      *globalvar directionY;*
      *directionX = 0;*
      *directionY = 0;*
      enum directions
      {
      up, left, down, right
      }
      global.components = [];
      global.components[directions.up] = [0,-1];
      global.components[directions.left] = [-1,0];
      global.components[directions.down] = [0,1];
      global.components[directions.right] = [1,0];
      (Additions to "move" in bold.)
      var dir = argument0;
      var components = global.components[dir];
      var dx = components[0];
      var dy = components[1];
      *if (dir == directions.left)*
      *{*
      *directionX = ann.x - 16;*
      *directionY = ann.y;*
      *}*

      *if (dir == directions.right)*
      *{*
      *directionX = ann.x + 16;*
      *directionY = ann.y;*
      *}*

      *if (dir == directions.up)*
      *{*
      *directionX = ann.x;*
      *directionY = ann.y - 16;*
      *}*

      *if (dir == directions.down)*
      *{*
      *directionX = ann.x;*
      *directionY = ann.y + 16;*
      *}*
      if (state == states.idle)
      {
      sprite_index = sprite[dir];
      if !(tilemap_get(tile_map, x_pos + dx, y_pos + dy))
      {
      *if (position_empty(directionX, directionY))*
      {
      x_from = x_pos;
      y_from = y_pos;

      x_to = x_pos + dx;
      y_to = y_pos + dy;

      x_pos = x_to;
      y_pos = y_to;

      state = states.walking;
      //sprite_index = sprite[dir];
      }
      }
      }

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

    Good afternoon, thank you for your contribution to the development of the GM community and interesting examples.
    I have a question, I did everything according to your lesson, but in GM 8.1, strange things happen because of the binding to deltaTime :) If we add the condition image_index = 2 (we will not go deep into the details) add instance_create (in general, any less costly) action) the character abruptly moves to the end of the animation. What can it be connected with? Perhaps it is necessary to refuse deltaTime and use other method?

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

    Hi, I was wondering, do I have to arrange any agreements for royalties if I make a game using code from this video and release it for purchase?

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

      No it's free to use. I didn't include any license so I appreciate you asking :)

  • @demonsweatthings8493
    @demonsweatthings8493 3 роки тому +2

    no matter what i do, i get this error:
    DoConv :1: illegal undefined/null use
    at gml_GlobalScript_move (line 2) - var components = global.components[dir];
    ############################################################################################
    gml_GlobalScript_move (line 2)
    cant figure out why. afaik i copied you exactly. i feel like it has to do with gm's recent update thing

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

      If you are using the new GML (GMS2.3+) make sure you are using functions correctly. Writing scripts directly without wrapping them in functions isn't valid anymore.

  • @dann790
    @dann790 2 роки тому +1

    Sorry for commenting here on this incredible old video, but I'm having the stuttering issue a couple people have mentioned in the comments, only instead of happening at every tile, it seems to be happening every frame. I tried making a post on the GMC forum about this, but they don't make posts visible until moderators accept them. Any idea as to what this could be? If need be I can show the code.

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

      Every frame? That is quite odd.
      I can't recall any possible issues outside the tile->tile transition. Does the stutter happen with any other animated objects?
      It's hard to discuss code in yt comments.
      What forum subsection did you post to? AFAIK only the tutorials section needs moderator approval.

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

      @@GMWolf Wow, you responded really fast! I'm assuming it's every frame because of how consistent it is, but it's just very common, so I can't say for sure.
      All sections need moderator approval for me, since I had made an account to post this, and the first 5 posts on a GMC forum account require moderator approval. I tried other animated objects, and it's just this object, so it's definitely not lag. Is there any good way for me to send my code to you that isn't youtube comments?

    • @dann790
      @dann790 2 роки тому +1

      I figured it out, I had messed with viewports and it made it look like it was shuffling back and forth when in reality it was just the camera not keeping perfectly on center with the character. Sorry about that!

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

      Great! Glad you figured it out!
      Happy deving!

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

    Fantastic Tutorial, I have it all up and running perfectly and smoothly in my initial room, but once I transition to the next room it no longer detects the tile layer, and the collisions stop working, do you know of any way to fix this?
    It is not a naming issue as all the tile sets and tile layers are named exactly the same as the previous room.
    If anyone has any ideas please let me know!
    Thanks again :)

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

      I think you would need to get the layer id and tilemap id again because you changed room. I would make those actual variables in the player object and in your transition object, re assign those variables to what's in the room you are going to.

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

      What I did to fix this problem, was move:
      var tile_layer = layer_get_id(“Wall”);
      tile_map = layer_tilemap_get_id(tile_layer)
      out of the create event of the player, and into the step event of the player. This way it checks every step of the game, instead of just at the beginning of its creation

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

      Also, could you let me know how you got the room transition working properly? Mine works for the most part, but it puts the player at the wrong x and y coords.

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

    Alright got this system down, just wondering if theres a way I can set a movement speed as I move within the tiles? With just this code alone it makes the player move too fast.

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

      Yeah, I'm fairly sure I even set a variable to control the speed...

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

      Hm, might have missed it then. I'll watch again.

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

      alright i figured out my issue, so basically in the step event of the player i did "t >= 0" instead of "t >=1"

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

      Ah yes, that would be it! :)

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

    Cool! Does anyone have an idea how to implement this for non-player objects, like enemies and the like? Specifically I'm trying to do something turn-based.

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

      The move functions that initiate the movement are still the same. You just have to call them in different places.
      For a Player object you call it on keyboard press events.
      For NPCs you could do it on a timer (for Pokémon style random movement) or when it's their turn for a turn based game.

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

    Using GMS 1.4, anyone know how to do the tile_width and tile_height thing? It doesn't like the #macro syntax.

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

      The #macro syntax is the new way of defining macros. You can still do it that way : docs.yoyogames.com/source/dadiospice/001_advanced%20use/010_macros.html
      But note this tutorial was really designed for the new tilemap system that doesn't exist in 1.4

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

    I am so confused on all these videos I watch for GMS2 everyone says it works perfectly but everytime I emulate these videos I get bugs that won't let me do anything. Is there something outside what the video describes that I need to do to prep for these videos? I am brand new just trying to get a few specifics done for me game it seems like D&D really is the only method that works for me as every code I try inputting I apparently do wrong somehow.

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

      Since this video game out, gml changed significantly.
      I recommend you check out some other videos that came out recently to learn gml first, and then come back to these videos and adapt the code.

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

    Hi. This is a great tutorial, and it works really well. But at the end I always crash using this line of code: tile_map = layer_tilemap_get_id(tile_layer); . Can you tell me some reasons why this would happen? My tileset is sparse, but it does exist in the layer, and I've double and triple checked my layer name on the previous line. Thanks for the great tutorial. I would just like to see it through to completion.

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

      Hard to tell without more information. Could you give me the actual error message?
      Also, might be helpful if you head over to the GMC (forum.yoyogames.com) and make a new post outlining the issue. Plenty of people there willing to help. If you mention me (@GMWolf) I'll be able to take a look too.

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

    Can anyone link me to a tutorial on how you would click on a grid square and have an object move there

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

      Whilst not exactly a tutorial, I did do a livestream where I prototype an RTS engine. If you are still looking for a good source, it could help.

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

    Its a great tutorial. I just have one question
    I did exactly as you did in the video. My character movement is a bit shaky when it finally reaches a grid block
    Is there any way to make it smooth?

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

      The best solution is probably to keep an accumulator.
      When you reach the end of a movement step, there may be some time leftover. Keep track of that to put it back into the start of the next step.

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

      I am sorry, I am new to Gamemaker, so i dont know what an accumulator is...

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

      Just a variable. In this case it would keep track of all the "unused" time.

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

      Again.. I am pretty new, so i dont know how to do that..
      If possible can you discord me the code segment needed?
      my discord tag: XXpoomaanXX#1899

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

      I wouldn't worry about it. Or ask about it on the forums. forum.yoyogames.com

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

    This tutorial is great! However, when walking, the sprite can sometimes snap back to its previous location for a split-second, causing stuttering. I noticed it in your video, and it occurs in my project as well. Have you found any possible solution? I played with the animation speeds and walk times, but to no avail. Thanks!

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

      I didnt notice it, have you made sure to clamp you t value to 1 maximum?
      Or did you mean with the animation?

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

      My code is:
      if (t >= 1) {
      walk_anim_time = 0;
      t = 1;
      state = states.idle;
      }
      It's not the animation itself, as it seems to run just fine. The error I'm having has something to do with the sprite returning to its previous position at the start of another run animation, causing the sprite to shake in the movement direction.

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

      Ah, ok. if by previous position, you mena the position in previous frame, rather than previous grid position, then yeah, I have noticed that.
      I think the best solution is to have a carry over varaible. So when you set your t = 0, keep track of how much t was left over, and use that in the next frame.

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

      How would I go about doing that, actually? I've spent the past couple hours trying different methods, but none of them seem to grab the left over t.

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

      t -= 1;
      accu = t;
      t = 0;
      In the code that starts the movement (forgot the name) t = accu.
      UA-cam comments make it hard to share code, if you need more help it's probably easier if you head over to forum.yoyogames.com and make a thread. If you mention me (@gmwolf) I'll be able to help you there. Other people will also be able to help.

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

    There is a way to do the same with gamepad?

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

      Yes just do the same, but instead of calling the move scripts on keyboard events do so with a gamepad button check.

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

      @@GMWolf oh, i understand, so i have to put the logic in the step event?

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

      Yeah I think so

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

      @@GMWolf Ok, really thanks :)

  • @tuckertcs
    @tuckertcs 4 роки тому +3

    Great tutorial but like 4x as fast as I can hear, think, and type. Slow down a lot, and pause between steps too.

  • @user-pp3zr3hp5u
    @user-pp3zr3hp5u 5 років тому

    At first it walks normally but then it's too fast

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

    Oh it's gms2.

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

      where you looking for other engines?

    • @The-Eric-Cartman
      @The-Eric-Cartman 6 років тому

      I think the person was hoping the tutorial was for gms1

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

      The movement works fine for me in gms1.4 xD probably doesn't matter now, im a year late.

  • @tomekipro1687
    @tomekipro1687 2 роки тому +1

    uncomplit

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

    Wish this was unity.

    • @GMWolf
      @GMWolf  6 років тому +2

      You should be able to adapt this code to unity fairly easily.

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

      Im no coding pro though and I don't understand this language

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

    If only this was in C# :/

    • @GMWolf
      @GMWolf  6 років тому +2

      Well, you can easily adapt the code to c# if you like:)

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

      All languages follow the same basic principles, as GM Wolf said, it's pretty easy to adapt code from one language to another, learn about Algorithms and Pseudo Code, it will make your life easier. :)

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

    You move way too fast

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

      I encourage anyone to pause and ponder while watching any tutorials :)

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

    Followed your code to the letter and am getting this error:
    Variable .state(100003, -2147483648) not set before reading it.
    at gml_GlobalScript_Move (line 5) - if (state == states.idle) {
    What am I doing wrong here?

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

    I know this is almost a 5 year old video now, but I also followed this guide exactly as shown. It would instantly crash all the time stating that
    Variable .state(100003, -2147483648) not set before reading it.
    at gml_GlobalScript_move (line 4) - if (state == states.idle)
    Neither me or my professor could figure out why it's happening, but the solution was to put the move script directly in the key down. Any idea why? Thanks for the video regardless, lots of great info!

    • @GMWolf
      @GMWolf  2 роки тому +1

      Are you using gms2.3? If so make sure you are using the new GML function syntax.
      Other than that kinda hard to debug over UA-cam comments, if you head over to the GMC (forum.yoyogames.com) and post a few more details I might be able to help you

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

      @@GMWolf Oh wow thanks for the fast reply. I'm only familiar with the latest version of Gms, what is the syntax change you are referring to?

    • @GMWolf
      @GMWolf  2 роки тому +1

      Previously each script was its own function. Notice I just write the instructions directly into the script file without defining a function.
      In the latest version of GML, you have to wrap the statements in a function declaration.
      I would recommend you read about functions in the manual. It should show you the syntax to define functions.

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

      @@GMWolf Ah, this makes more sense now! Thanks so much for all the information, I'll be reading into it shortly.

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

    Looking into crafting a system similar to the South Park games where distance from the camera changes perspective a little bit.
    I think this will help and then applying an isometric view but making the player think it’s a 2-D room..