#5857 - sgeos - Sat May 10, 2003 11:25 pm
What is generally the best way to approach climbing inclines in a platform physics simulation? The down part is easy, as it comes as a side effect of gravity.
-Brendan
-Brendan
sgeos wrote: |
What is generally the best way to approach climbing inclines in a platform physics simulation? The down part is easy, as it comes as a side effect of gravity. |
tepples wrote: |
Are you talking about a rolling object or a legged object? |
tepples wrote: |
For rolling objects, you'll have to split gravity into components perpendicular to and parallel to the surface. |
tepples wrote: |
The equation for this involves the slope. |
tepples wrote: |
Walking objects tend to act much more nonlinearly, |
tepples wrote: |
and you may have to hardcode movement characteristics for each slope you're planning on using. |
sgeos wrote: | ||
Assuming that the slope is defined (our equation is not x = n), and gravity is apllied along the y-axis (probably down), does not gravity only have a component perpendicular to the surface? |
Code: |
|
| | | g | | _,-' | _,-' v _,-' _,-' _,-' _,-' |
Code: |
a
_,-': <' : \ : \ : b \ : \ : _,-' \: _,-' v _,-' _,-' _,-' _,-' |
Quote: |
How would you store the slope? Should each tile have a slope |
Quote: |
I'd want to read the terrain to cope with curves. (Imagine terrain that looks like a sine wave, a few tiles high with a period four to eight tiles.) |
Code: |
x _,-': <>R B: \ : G \ : | y \ : | \A: | \: V R<: _,-'B: _,-' _: _,-'A R| : ^^^^^^^^^^^^^^ |
tepples wrote: |
[SNIP diagram, see post above] This represents the same gravity and the same surface, but the gravity vector has been decomposed into vectors 'a' parallel to the surface and 'b' normal to the surface. The acceleration of the ball is 'a' times a constant slightly less than 1 that accounts for rotational inertia. (A full Newtonian analysis, including angular momentum, is beyond the scope of my physics abilities at 2 AM.) |
Quote: |
Friction is proportional to 'b' and depends on the characteristics of the surfaces. |
Quote: |
Each tile number should have an associated slope. For example, if tile 34 is a piece with slope +1/2, then store 0x80 (fixed point for 128/256) in slope_table[34]. |
Quote: |
For a Sonic clone, an approximation of slope every 8 pixels isn't going to hurt anybody, especially because grassy terrain is slightly irregular anyway. |
Code: |
V-----> _,\ y x _,-'R\/\ _,-'A B\ ^^^^^^^^^^^^^^: A_,-'B: _,-' _: _,-'A R| : ^^^^^^^^^^^^^^ |
Code: |
_,--: _,-' _: opposite _,-'A | : ^^^^^^^^^^^^^ adjacent |