GM: friction
From GMpedia.org Wiki
|
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:
- 5
- 4.5
- 4
- 3.5
- 3
- 2.5
- 2
- 1.5
- 1
- 0.5
- 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;
- -5
- -4.5
- -4
- -3.5
- -3
- -2.5
- -2
- -1.5
- -1
- -0.5
- 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.

