GM: friction

From GMpedia.org Wiki

Jump to: navigation, search

friction

Type: variable
Globalism: Local
Editable: Yes

The friction variable indicates the friction to subtract from the absolute value of the speed each step. This should be set in the format pixels per step.

This means that the friction variable will make the speed variable closer to zero in each step.

Contents

[edit] Examples

[edit] Positive Speeds

In the create event, speed will be set to 5 and friction set to .5:

speed=5;
friction=.5;

If we now evaluate the speed variable in each step, these will be the findings:

  1. 5
  2. 4.5
  3. 4
  4. 3.5
  5. 3
  6. 2.5
  7. 2
  8. 1.5
  9. 1
  10. 0.5
  11. 0

After the speed variable reaches 0, it no longer changes.

[edit] Negative Speeds

In the create event, speed will be set to -5 and friction set to .5:

speed=-5;
friction=.5;
  1. -5
  2. -4.5
  3. -4
  4. -3.5
  5. -3
  6. -2.5
  7. -2
  8. -1.5
  9. -1
  10. -0.5
  11. 0

After the speed variable reaches 0, it no longer changes.

[edit] Acceleration

In order to actually speed up an object, making a negative friction will therefore increase the speed of an object each step.

[edit] See Also

Personal tools