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.
- Навчання та стиль
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!!!
great video man, really appreciate it!
Thank you very much bro! You are the best!!
thanks, you help me soo mutch!
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?
Thank you so much
thank you SO MUCH
how do we stop the vertical(up down) movement and limit only left to right?
You are my hero
Thank you :D
thanks, man
How can i make a character move based on a dice roll?
Great this works well, now is there a way to use this style of movement in grid-based style
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)
@@thiti5179what about slowing the object down as it reaches it's target?
thanks :)
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?
It should not matter.
Just mess around with the numbers for the "distance_to_point" part of the code.
my obj also moves to the right side of the mouse. then shakes
Hmm, maybe the sprite size does matter.
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 :)
I’m trying the distance from point thing and it shows an error
same
OHMYGOD
How do you glue one Sprite on top of another ? I can't figure it out
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
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
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!
Etredal will they stay together if the bottom Sprite moves ?
yes
What should i do if it doesnt move to the point?
i had the same problem in the STEP event i wrote spd = 0 ; instead of speed = 0; :S:D
do uu have a github
My Chess tutorial series is on github but not these older videos. You can check the descriptions for a link!