- Home /
Need help with strategy terrain.
Hey guys, got a question here ill be glad if you can help. Im making a strategy game like Stronghold 2.I want to create a sort of terrain that lets you build, instantiate prefabs on it and doesnt instantiate prefabs when the terrain looks is uneven just like Stronghold 2. Im not sure whether I have to create a voxel terrain which i really dont know how to do. Can someone help please. Thanks
Answer by Kiloblargh · Feb 23, 2013 at 07:36 PM
You shouldn't need a voxel terrain for a traditional strategy game, that would be more for something like if you were making a 3d version of Worms.
You need a ghost building that follows the cursor, can turn red or green, and while it is moving you need to check every terrain vertex in the the building's footprint against its neighbors and if the slope is greater than a certain point, or the overall slope corner-to-corner is above a certain value, then you can't build, if all of them are less, then you can build.
[edit] Actually, you don't need to compare verts directly, if your terrain will not change during the game. I've been working on my own dynamic terrain and haven't actually used Unity's terrains, but they give you a lot of useful functions to work with. Check this one out:
http://docs.unity3d.com/Documentation/ScriptReference/TerrainData.GetSteepness.html
It's going to be a lot of scripting to get the building placement effects fully working the way you want and you're probably not going to get someone to write it for you on this site, so crack open the docs and get to reading.
Thanks allot! what sort of docs shall I read though to help me with this
Everything having to do with TerrainData, and Transform, and Colliders, and Raycasts. Once you get to the issue of placing buildings next to other buildings or on top of moveable units, might want to use something like: http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html
Your answer
Follow this Question
Related Questions
Instantiating multiple objects, Destroying and instantiating on trigger + delay 0 Answers
Instantiate trees on terrain with perfect height. 2 Answers
Making a particle effect parallel to the slope of a terrain 1 Answer
Flowing water in my voxel terrain 1 Answer
How to make a voxel terrain generate all around the start point 1 Answer