Game Development Community

dev|Pro Game Development Curriculum

Road Mesh as Terrain Border

by Kevin Mitchell · 03/23/2013 (6:13 pm) · 18 comments

Terrain border was one of my biggest fear when it came to making my game. Controlling were the player could and could not go seemed so hard. But this seemed to do the trick very well!

Placing a border around the entire island only took about 30 minutes with hardly any tedious foolery.

To achieve this I first drew a single road mesh around all of the desired borders of the ground.
To change the height of the border i went into the mission file and did a find replace in selection to make the width 1 and the height 100.

After that all i had to do was select the road in the editor and raise it 50 units.

The rest was making sure the on cliffs that there was not any sections that curved out too far where the player could get trapped. Next was to make the height higher for areas where I could take a leap of faith and possible jump over the border.

Last was to make the entire border transparent for debugging purposes. And making the road mes non render-able. With it non-render-able I did some FPS testing to see if it would hurt performance. I have not seen anything as of yet. Even doing random crashes with my hover board did not cause any crashes or any kind of issue were one could get stuck in the border.





I'm so freaken SQUEEK right now~~!

YAY!
media.tumblr.com/tumblr_lxg0nmTuIy1qjlunc.gif

#1
03/24/2013 (11:40 am)
Genius :)
#2
03/25/2013 (2:25 am)
I like the idea. Nice work.
#3
03/25/2013 (4:43 am)
The only thing I have to figure out is how to make it non-collide-able with rockets and such.
#4
03/25/2013 (7:15 am)
I use a somewhat modified version of the good old vehicleBlocker. With a flag I can block the player-class or the AIPlayer-class. The only downside is that this kind of blocker aren't rendered in the editor, so it is a little tricky when adding these.
#5
03/25/2013 (12:05 pm)
Great work on this one -- this will be very helpful.
#6
03/28/2013 (8:21 am)
I'm also using the meshroad for keeping players away from the edge of the map (in the shape of a wired fence). There are several issues though; If the player jumps agains the side of the mesh it can get stuck pretty fast. Another issue is that during loading of the level, meshroads might not load entirely correctly and rendering can get a bit messed up (in your case with transparent walls not an issue, I guess).

If, in your case, you want to replace the meshroad with a normal mesh you can export it to collada, turn it into a collision mesh (in 3ds max or something) and import it back again. Too bad for me is that it's without material mapping, so I have to live with the 'getting-stuck-in- barbed-wire-if-you-jump-in-it' effect ;)
#7
03/28/2013 (10:36 am)
Whats your wall thickness? I know if a mesh is too thin then the collision calc can be delayed.
#8
03/31/2013 (8:36 am)
That looks like a bad solution. You are on an island, so you could just leave it open and let the players swim to oblivion, if they think they can do it.
But on non-island levels you would need a border to block, but there this is also not very good. I already used collisonmesh-only blocks, but as I already stated, it blocks the player, but also projectiles, so rockets will explode on the invisible wall for example, which is not nice.
#9
03/31/2013 (12:23 pm)
I'm more likely to take this class and modify it for my purposes so things like projectiles will ignore them.
#10
03/31/2013 (1:07 pm)
We've been thinking that it should be relatively simple to modify the convex shape class to have flags for visibility, collision, and loscollision that could be toggled as needed....
#11
03/31/2013 (5:45 pm)
I ddont think it would be hard, but its not on my top list of things to do until I have magic and other things implemented. Plus I don't like editing a class directly so I duplicate it as a new object.
#12
03/31/2013 (6:17 pm)
Quote:
I don't like editing a class directly so I duplicate it as a new object.
Think of it as adding additional functionality to an existing "boring" class... the committee has discussed doing so but it would be great if a solution was presented ready for implementation ;)

BTW, nice adaptation of the road tool. That's one I never thought of.
#13
03/31/2013 (9:06 pm)
That's true but the things I'm doing now is a part of my packet. I as of now just want to make an add on to the engine and not directly change its structure. After this though I do plan on jumping in to MIT I'm loving the things I see happening and would like to enhance everything with the community.
#14
04/01/2013 (6:40 am)
Awesome resource you have contributed here. I have been playing with many ideas of how to stop my players running atop of the game board so to say and then this comes up(one bad idea was to add collision boxes to certain trees : ) ).

Utterly great thinking and a huge help. Thumbs up times one million!!!
#15
04/13/2013 (6:06 am)
Konrad Kiss has a resource that lets a terrain material stop a player.
#16
04/13/2013 (9:22 am)
@Kevin, (late reply... somehow didn't got the notifications)

The 'wall thickness' is very thin (0.1) because I use transparency with the single-sided material.

i-dropper.net/torque/MeshRoadFenceSmall.jpg
[+]


The 'wall' does not run in straight lines, if it is too thick then 'the other side' will appear in the curves and look strange. My aim is to be able to define different materials for either side, but I didn't got there yet.

For the meantime I damage the player on collision to discurage running into it like this:

if (%col.getClassName() $= "MeshRoad")
   {
      %isFence = startsWith(%col.getName(), "Fence");
      if (%isFence == true)
      {   
         serverPlay3D(DeathCrySound, %col.getTransform()); // play sound
         %obj.applyDamage(5); // hurt the player
         %obj.damage(0, %obj.getTransform(), 1, "Scratched");
      }  
   }
#17
04/13/2013 (1:47 pm)
@andy
tried that had some issues plus I like multiple solutions.

@nils
I've seen several collision issues with thin objects.
#18
04/26/2013 (4:22 pm)
It seems that this solution will fail from time to other(perhaps due to the thin objects). I found another solution here. I simply just make cubes that is given visible mesh and then make them non render-able. This works for world borders. It might not be a great solution for lakes etc.