# Slope physics

This topic is 1417 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm using newtons laws in my snowboarding game to move my character down the slopes. I've considered using a physics engine but I don't I need that just yet.

To compute acceleration and therefore velocity, I'm using the standard slope calc:

Acc = grav * sin(theta)

I then add or subtract the friction x force normal calc (mu * grav * cos(theta)) depending on whether the character is going down a slope or up. At the moment, the slope is calculated along the edge of the snowboard so it doesn't matter which way it is facing, it's either going down a slope with positive acceleration or up a slope with negative acceleration.

I've cancelled out mass here, theta is the angle of the slope with reference to the ground plane and mu is the coefficient for friction - I've currently got that at 0.2

This looks like it works quite nicely, when the character is moving down a slope, I increase the velocity by the acceleration by my delta time and it appears pretty natural. The only point it looks a little unnatural is when the character is travelling pretty fast down a slope that faces another opposite slope. He almost goes the same height as it came from on the upward slope and I wouldn't expect this. I would have thought that he would slow down a lot quicker.

So my question is am I calculating this correctly? Is it enough to apply negative acceleration and negative friction or should I be applying some further force when slowing the character going up an incline from kinetic energy?

Thanks

##### Share on other sites

No, it looks like you're mathing everything okay.

http://hypertextbook.com/facts/2007/TabraizRasul.shtml

If you don't want your character to move as far, just increase the friction coefficient. The coefficient of wet snow is generally 0.3-0.6 when in contact with rubber, so it it's probably a little higher than 0.2 for snow in contact with a snowboard.

Also keep in mind there's a lot of other forces at play here besides just friction. There's additional soft-body collisions happening when the snowboard cuts through the snow, there's the air resistance that goes into affect when the snowboarder goes fast enough, there's the difference between the top layer of snow that's wet and the lower layers that're probably dry that have different affects on the board. In the end, though, your game is going to be an estimate of reality, so don't be afraid to play with some numbers to make things look and feel right. It may not be mathematically correct, but a lot of times, it's all you can do :)

I'd recommend dialing up the friction coefficient, and adding air resistance, and that should be good enough for a semi-accurate simulation.

##### Share on other sites
Great answer, thanks! I'll increase the coefficient for air drag relative to his speed and see what happens. I also need to increase when he's going through powder and reduce it when he goes over ice.

Who needs physics engines anyway! ;-)

##### Share on other sites
Something I also forgot about, my character increments after applying velocity are based on units that are on a slope of varying degrees but I'm just adding the resulting velocity to the x and z values of my character and not his z value, ie I'm not adjusting his xz positions for the slope he's on. This will definitely slow him up a bit too - schoolboy error!

##### Share on other sites

I think when going up the other slope, potential energy will increase while kinetic energy will decrease( unless there is additional forces being applied that will increase the object velocity and in turn its kinetic energy ) . So you may factor that in and adjust the forward acceleration accordingly...

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 12
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632989
• Total Posts
3009744
• ### Who's Online (See full list)

There are no registered users currently online

×