Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to make an object move towards the cursor?

Jason

Awesome Bro

Okay so I've decided to learn a few new techniques with GM8 (Finally made the full transition, and bought the Pro edition)

What I want to do is make it so an object will move towards the mouse cursor once I click somewhere on the screen, I'd assume it would be a move towards event, and I tried cursor.x and cursor.y, as well as mouse.x and mouse.y but I'm probably way off, since it doesn't recognise either of those variables.

Another question, I'd like to know a good place to start learning GML properly, we've just started it in college, and I can do a few basics, but the course seems to be moving too slow for my liking, so I'm gonna' speed the process up, any help?

Cheers.
 
I dont know if this if this is what you are looking for:



mouse_check_button(numb) Returns whether the mouse button is currently down (use as values mb_none, mb_left, mb_middle, or mb_right).


mouse_x X-coordinate of the mouse in the room. Cannot be changed.
mouse_y Y-coordinate of the mouse in the room. Cannot be changed.


Again, this was ripped straight from the tutorial so I do not know. D:

But I guessing you could check the mouse X & Y location along with if the mouse button is down then move it to the the variable's value.


Also, I found the best way to learn GM is through the tutorials themselves. They are super useful and handy and give you some good pointers and basics. I honestly dont know how long you have been using GM, so I apologize if you have already check these out. Im sort of new to GM. x:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top