Hi
Im a bit ashamed about asking for help abot something this simple, but im having a hard time wrapping my head around this for unknown reasons.
Hopefully the answer will come to me while writing this post, but maybe not.
I am using FloatingPoint possitions for the Objects.
...
Like the Topic says, ( 1 ) i have an Object affected by Gravity, and ( 2 ) i want to be able to slow time down ( to a complete pause or even doubble speed ).
First i will explain how this works at normal speed, half speed, and them quarter speed. Hopefully this will be able to shed some light on the issue.
...
( - NORMAL SPEED -)
Allways
- Object add 1 * 1 to Gravity_
Allways
- Object set Ypossition to 'Object Ypossition' + Gravity_
The above code results in Object moving exactly 1 pixle during the cource of 1 Game Frame.
- 1 is added to Objects Gravity_
- Object moves 1 pixel
...
( - HALF SPEED -)
Allways
- Object add 1 * 0.5 to Gravity_
Allways
- Object set Ypossition to 'Object Ypossition' + Gravity_
The above code results in Object moving exactly 1,5 pixles during the cource of 2 Game Frame, when it should be 1 pixel since speed is only halved and should move 1 pixel during 2 Game Frames.
- 0.5 is added to Objects Gravity_ ( total 0.5 )
- Object moves 0.5 pixel ( total move 0.5 pixels )
- 0.5 is added to Objects Gravity_ ( total 1 )
- Object moves 1 pixel ( total move 1.5 pixels )
...
( - QUARTER SPEED -)
Allways
- Object add 1 * 0.25 to Gravity_
Allways
- Object set Ypossition to 'Object Ypossition' + Gravity_
The above code results in Object moving exactly 2,5 pixles during the cource of 4 Game Frames, wich is not correct since game is at quarter speed and should move 1 pixel during 4 Game Frames.
- 0.25 is added to Objects Gravity_ ( total 0.25 )
- Object moves 0.25 pixel ( total move 0.25 pixels )
- 0.25 is added to Objects Gravity_ ( total 0.5 )
- Object moves 0.5 pixel ( total move 0.75 pixels )
- 0.25 is added to Objects Gravity_ ( total 0.75 )
- Object moves 0.75 pixel ( total move 1.5 pixels )
- 0.25 is added to Objects Gravity_ ( total 1 )
- Object moves 1 pixel ( total move 2.5 pixels )
...
( - SOLUTION -)
In the Half Speed example, to end up with the correct number of pixels moved ( 1 pixel moved during 2 Game Frames ), i have to add 1/3 to Graity_ each Game Frame instead of 0.5.
- 0.3333 is added to Objects Gravity_ ( total 0.3333 )
- Object moves 0.3333 pixel ( total move 0.3333 pixels )
- 0.3333 is added to Objects Gravity_ ( total 0.6666 )
- Object moves 0.6666 pixel ( total move 0.9999 pixels )
In the Quarter Speed example, to end up with the correct number of pixels moved ( 1 pixel moved during 4 Game Frames ), i have to add 1/10 to Graity_ each Game Frame instead of 0.25.
- 0.1 is added to Objects Gravity_ ( total 0.1 )
- Object moves 0.1 pixel ( total move 0.1 pixels )
- 0.1 is added to Objects Gravity_ ( total 0.2 )
- Object moves 0.2 pixel ( total move 0.3 pixels )
- 0.1 is added to Objects Gravity_ ( total 0.3 )
- Object moves 0.3 pixel ( total move 0.6 pixels )
- 0.1 is added to Objects Gravity_ ( total 0.4 )
- Object moves 0.4 pixel ( total move 1 pixels )
...
The solutions in the later part of this post has mainly been a result of my guesswork and testing, i do not understand the logic behind any of the numbers ( 1/3 1/10 ).
My problem is:
When 1 Game Frame spans acoross multiple Game Frames ( Time is slowed down ), i dont know how to correctly increase Gravity_ each Game Frame ( so that in the end, distance traveled will be exactly the same as if Normal Speed )
I know that exactly what im asking about might be a bit vague and maybe not very clear, but i hope i have managed to make you understand my situation through the examples.
Im still working on this and very much appreciate and need all the help i can get, so i can get this working correctly and move on.











Reply With Quote

