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 movement limited methods

Author
Message
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 16th Jan 2009 02:08
I am thinking of ways I can make it so that the player cannot go past certain areas in maps, like hilly area not going up certain parts, etc. I though of 2 methods that this can be done, and I want to see what you guys think. I would test this if I had terrain to test it on, but I have nothing, and can't make them. I can make the terrain in 3D modelers, but applying a texture is where the problem comes in.

First thought, and assumed worse method, but more flexible.

This uses math to calculate the slope of the hill/mountain, if the angle is to high, you cannot go any higher. This method makes it a lot more flexible and easier to implement to a certain extent, but from what I noticed, math is pretty slow in DBPro.

Second, assumed easier, less flexible, but takes longer to do.

For every map, you basically make a second image of it in bird's eye mode, and take it to photo shop. You make lines where you cannot pass, and make the rest another color. Texture the result to a plane below the terrain, make it invisible to camera 0, and sits there. Then, make another camera above the character, place an arrow where the character is, and check for some form of collision on colors with the lines somehow (with terrain and player hidden from camera 1 or whichever you made it) and disable the character from traveling there, and you can use the other camera to use as a radar too, placing the camera's frames on the screen to see the locations. But the more difficult part about this is the collision with the line, if that can be done, is this better or worse than the other one if you just want basic collision?

The reason I ask this is because I am about to get T.ED (I only have a $30 limit, and I already have Cartography shop, so I do not need 3DWS right now.) and I want to make some form an "invisible" wall system where you cannot go. Is there a specific method you use? Why do you use it? Why is it better than the other options? If possible, can someone upload a simple, hilly with a path 3D landscape textured for me to test with, I would use matrices, but they are to slow. I like speed with decent quality looks. But if anyone can help me with this, it would be greatly appreciated.

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Jan 2009 03:18 Edited at: 17th Jan 2009 03:28
Wow, that second one sounds overly complicated . The first method you listed sound to be by far the better. I bet if you search "Terrain Slope" or similar you can find a function that will do this.

If you can't, you could probably do it the easy way. Before the player moves, record its position. After it moves, check the new and old y positions. If they are too far apart, move the player back to its old position.

Now, if you need to place invisible walls that don't correlate with the hills, you should probably use a 2-dimensional array. Divide the landscape up into imaginary "tiles." In the array, store which tiles are impassable and which ones are open. When the player moves, divide their position by the tile width and check the proper location in the array to see if the move is legal.

Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 17th Jan 2009 06:35
Heh. I would love to attempt that, but I learn best when I have something there to show exactly what is going on.. I might attempt the slope idea, the array one does not sound 3D friendly. When I get a .x terrain, I will try, but I cannot till then...

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 17th Jan 2009 15:49
They're quite easy to make in Blender using the sculpt tool, here's a small one: (attached)

Attachments

Login to view attachments
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 18th Jan 2009 00:17 Edited at: 18th Jan 2009 00:22
Finding the angle upward the player has moved is actually far easier than it sounds. Basically, every frame you move the player forward, then up/down according to the terrain height. So store these in two variables (of course with actual values though):



Once you know how far the player has moved forward and up you can get the angle he's moved upward using trig. Tan( ) will the a real number equal to the side opposite the input angle divided by the side adjacent to the input angle. So you know that tan( Angle ) = UpMove/ForwardMove, or 4.0. However we need to know angle, so we use atan, which takes a number equal to UpMove/ForwardMove and spits out the angle. So ATan( UpMove/ForwardMove ) = UpAngle. Then you can check if this value is greater than a certain value, and if it is, move the player back to where he was before he moved that frame.

So to clarify, he's what I mean:



Obviously that's pseudo-code; you can't just copy and paste it. But hopefully it gives you an idea of what I'm talking about.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 18th Jan 2009 03:11
@AndrewT:
But then wouldn't that allow the player to move sideways up a mountain? That is, the player would be able to turn his side to the mountain and then move forward at a very slight angle to the mountain in order to go up a large hill...

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 18th Jan 2009 03:38 Edited at: 18th Jan 2009 03:39
Ya, I suppose you're right. I guess the only practical way then is to get the normal of the poly below the player, and if it's pointing below a certain direction then the player cannot advance.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 18th Jan 2009 14:42
Quote: "I guess the only practical way then is to get the normal of the poly below the player, and if it's pointing below a certain direction then the player cannot advance."

Hmm... I should try that the next time I need to limit terrain movement. Good idea

Login to post a reply

Server time is: 2024-09-28 00:25:04
Your offset time is: 2024-09-28 00:25:04