Public Group

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

## Recommended Posts

I'm looking to make the gradiant of my terrain slow/stop characters. I realise this means taking the normal of the plane below the character, but I'm quite bad with math and was wondering if anyone had an example or simple explaination on what I'd do with that normal to use it to slow my characters. I know this is quite a nub question and put in very nub terms.. but thats me :) Any help/suggestions is greatly appreciated, thanks.

##### Share on other sites
Do you mean, rather, that climbing should slow your character?

Difference of gravitational potential translates to a difference of speed between t=1 and t=2:

(v1)2 + 2g (z1-z2) = (v2)2

##### Share on other sites
Well, I did say I'm not good with math. The equation there isn't laid out in anyway similar to what I ever learned at school.

What I was looking for can be summed up as:
The greater the gradient of the terrain/face, the slower the speed a character can move on it. I'm also realising at the moment that it requires the gradient of the face being approached also, otherwise it would have problems going down steep gradients..

Unless I'm going about my goal in the wrong manner, then please someone tell me :).

##### Share on other sites
Again, you don't need gradient: the only important thing is the altitude difference between the starting point (z1) and the arrival point (z2). The higher the arrival point is above the starting point, the lower will be the speed when that point is reached, so moving up makes you move slower.

##### Share on other sites
An easy way to vary the speed depending the slope of the terrain would be to use the normal's Z component squared as a speed factor (i.e. speed in the direction of movement). It is fairly realistic, but not physically correct (that would require simulating how the object converts energy into motion). Some sample values:
    slope    Z    Z2 speed factor      0°    1.0     1.0   (100%)     45°     .7      .5   (50%)     60°     .5      .25  (25%)     80°     .17     .03  (3%)     90°    0.0     0.0   (0%)
Now if you measure speed on the XY plane, you have to multiply the object's speed by the cosine of the slope (which happens to be the normal's Z component!), so instead of Z2, you would use Z3. Some sample values:
    slope    Z    Z3 speed factor      0°    1.0     1.0   (100%)     45°     .7      .35  (35%)     60°     .5      .13  (13%)     80°     .17     .005 (½%)     90°    0.0     0.0   (0%)
To use the speed factor, you simply multiply it times the normal speed.

Note: this affects both incline and decline.

##### Share on other sites

so you want to implement gravity.
contact force:
when an object is placed on a surface , the surface exerts a force equal
to the mass of the object * gravity to keep the object from falling.this
force is called contact force , and it's symbol is R.
note: this force is perp to the plane , so it has the same direction as
the surface's normal.
gravity:
it's the force acting down on every object , and has a constant of 9.8 (there are others).
it has a symbol of g. gravity provides a force of 9.8 per gram. so to get how much
force is acting on an object , we multiply it's mass (m) , and the gravity constant.
inclination:
when a surface is inclined , gravity has to be resolved perp and parrel (down the plane).
you can see from the pic that theta = 90-(180-90-angle of inclination) = 90-90+aoi = aoi.
now twe have a right angle triangle, we can use trig to get the other two sides.
cos(theta) = PerpForce/mg (arrange to get perpforce)
PerpForce = mg*cos(theta)
parrelforce = mg*sin(theta) (same proc)

the parrelforce will make the object head down the plane , and if there is no opposing
force it will. your object provides force that moves it up the surface . so it has to be greater
than the surface pulling it down. when the inclination increases the force moving him
down increases , untill it reaches a limit (mg*1) . you decide how much force the
object puts in climbing , therefore deciding when a surface becomes un-climbable.
surfaces also provide friction (f) , which is a force acting in oppisite direction of any
motion.
the way i see it , if you have the plane normal, you can get the angle the plane makes with
horizontal plane by getting the angle between the two plane normals.the horizontal
plane ,would be the plane the foward/back vector makes with the left/right vector.
what ever you have those assigned to.the angle you get is theta, just sub that in this
eqn mg*sin(theta) (same proc) , and you get the resulting force. so subtract that from
the objects moving force to get the resultunt force.

##### Share on other sites
I actually have gravity, just not in a sliding manner. It works only directly downwards on the terrain. But thanks for the extra math.. I'll take a read of it now.

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5

• 13
• 13
• 60
• 14
• 15
• ### Forum Statistics

• Total Topics
632124
• Total Posts
3004248

×