le_Liam
Aug 27th, 2024 (edited)
22
0
Never
This is comment for paste Approach()
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. here is an updated code for newer GMS2 versions like (v2024.06.2.162)
  2.  
  3. function Approach(_value,_value_to,_amount)
  4. {
  5.  
  6.     if (_value < _value_to)
  7.     {
  8.         _value += _amount;
  9.    
  10.         if (_value > _value_to)
  11.             return _value_to;
  12.  
  13.     }
  14.     else
  15.     {
  16.         _value -= _amount;
  17.         if (_value < _value_to)
  18.             return _value_to;
  19.  
  20.     }
  21.     return _value;
  22. }
  23.  
  24. Keep in mind you can't write the function and expect it to alter a value on its own. You have to write the whole instruction, like this:
  25.  
  26. y = Approach(y, target_y, move_speed);
  27. and not
  28. Approach(y, target_y, move_speed);
  29.  
Advertisement
Add Comment
Please, Sign In to add comment