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.

DarkBASIC Professional Discussion / controlling an object over a terrain loaded with advanced terrain

Author
Message
mnemonic
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 6th Jun 2012 17:03
Ok! So I've loaded a heightmap terrain into DBpro using the advanced terrain commands. I know how to make an object following the contour of the terrain. But concidering that my heightmap contains mountains, and therefore tilts in different angles. Like a mountain maybe tilts 90 degress up. (it's impossible to walk in a 90 degree angle straighnt up) But let's say a tilt up to 45 degrees is possible.

The thing I want to do is checking the angles and let the player follow the countour if the angle at that given location is lower than eg. 46 degrees.

My player is an FPS controller.

How can I do this?

www.memblockgames.com
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Jun 2012 17:23 Edited at: 6th Jun 2012 17:31
Look through this post about slope angles: http://forum.thegamecreators.com/?m=forum_view&t=197138&b=1

A logical solution to your problem, is to calculate the X angle between current position and the new position; based on your current control system; but only move to the new position if the angle is in your desired range.

Consider also the Atan full command, which calculates the angle between two locations:


Consider also another solution; limit the height of which your player can step up. So, if the difference in location on the Y axis is greater than the maximum step height, do not move to the new location. In coding terms:


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jun 2012 17:36
It would be simpler to work with the trig values - no need to convert to an angle.

You could do something along the following lines:

1. record current player's XYZ position on the terrain
2. move the player and record it's new XYZ position on the terrain
3. calculate the ratio (newY-oldY)/(distance moved)
4. if ratio greater than some fixed value then move player back to it's original position (e.g. a value of 0.707107 corresponds to an angle of 45 degrees - sin(45) = 0.707107).

Login to post a reply

Server time is: 2026-07-08 21:14:08
Your offset time is: 2026-07-08 21:14:08