Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Terrain help

Author
Message
Tom J
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Essex, England
Posted: 30th May 2006 14:28
When it comes to terrains how can I make it so that in a game the person you play as cannot climb steep hills but can climb those with a low gradient?

The Url to my site actually works now!
Relativity
19
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 30th May 2006 18:54
Get the normal of the polygon the player is climbing. If the angle between the normal and the XZ plane is too small, then you know the plane is too steep to climb. You can find the angle a between two vectors using this formula

n = normal vector
x = vector in the XZ plane
a = angle between the vectors
||q|| would be the length of vector q.

cos a = ( n * x ) / ( ||n|| ||x|| )

You're going to need a basic understanding of vector math to do this. Check out this site (http://www.geocities.com/SiliconValley/2151/math3d.html) to learn more about vectors.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 30th May 2006 19:47
height difference between moves = destination height - current height

slope of a line = y/x

so figure how steep you want the limit, store the slope calculation as a constant. (cause that number doesn't need to ever change)
If the height difference is greater than the slope allowed, don't move.

This method is more dependent on how faster you're moving. Moving very slowly, you can most likely still climb steep hills. So its not a great method, but computationally easier than processing the vectors all the time.

"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 30th May 2006 22:41 Edited at: 30th May 2006 22:42
Quote: "height difference between moves = destination height - current height

slope of a line = y/x

so figure how steep you want the limit, store the slope calculation as a constant. (cause that number doesn't need to ever change)
If the height difference is greater than the slope allowed, don't move.

This method is more dependent on how faster you're moving. Moving very slowly, you can most likely still climb steep hills. So its not a great method, but computationally easier than processing the vectors all the time.
"


I second it all. Though I have some words to say about it.

The "moving slow problem" can be solved by not calculating the height difference between destination and current height, but using a set distance in the direction the player will move instead of the destination height.

Besides that, the command intersect object(Object, x1#, y1#, z1#, x2#, y2#, z2#) will give you the exact distance of the intersection point to the coords of x1#,y1#,z1#. If you take y1# = 0.0 and y2# a point above the terrain, then that means that the distance# = height# of the terrain.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-11-26 19:47:22
Your offset time is: 2024-11-26 19:47:22