0
\$\begingroup\$

Currently, I have this in my step event.

y += sign(mouse_y - y);

I am trying to adjust how fast it goes towards the mouse so I can have it scrolling up and down the screen. sorry if this has been asked before I need an updated answer.

\$\endgroup\$
2
  • \$\begingroup\$ It has been a while since I used gamemaker studio 2 only recently I have started messing with it again. \$\endgroup\$ Jul 16, 2021 at 18:04
  • 1
    \$\begingroup\$ Do mean increasing/decreasing the change by a fixed amount or do you need something more sophisticated? If you use something like y += sign(mouse_y - y)*scale; the speed would triple for scale=3 or go half as fast for scale=0.5. \$\endgroup\$
    – Pikalek
    Jul 16, 2021 at 19:01

1 Answer 1

1
\$\begingroup\$

If your goal is to change the movement rate by a fixed amount you could use something like:

y += sign(mouse_y - y)*scale;

Setting the variable scale to 3 would triple the movement rate whereas setting it to 0.5 would halve it.

For more sophisticated changes you could modify the scale in your game loop or update function to gradually speed up or slow down over time.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ thanks this helped me with what I needed Perhaps you could give me that sophisticated version later :D \$\endgroup\$ Jul 16, 2021 at 22:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .