I'm not using the Unity Terrain because it lacks certain features.
Amongst them, you cannot tile them:
You cannot create concave walls or make holes in it:
No custom textures, no detail textures, awful sculpting tools... the list goes on and on. So I imported my own Terrain as a Mesh. The collision works perfectly, however raycasting onto the Terrain is horribly inaccurate. Unity seems to compress the Mesh Collider depending on distance to player. See the video linked below. Since Unity is (by my knowledge) the only Game Engine that supports convex colliders, how do other game engines create Terrain colliders?
For a racing game or a RTS or RPG the colliders are no problem, but for a shooter it's unacceptable. Here's a video showing the problem:
https://youtu.be/coiFS6IT4wI
I've researched long and hard and there seems to be no known solution for this. So my question remains, if it's possible at all, how can i create large scale Terrains for Unity? This problem makes it completely impossible for me to create outdoor scenes. There HAS to be some kind of solution.
1) Raycasting script:
//Spread
float spreadAmount = Mathf.Lerp(spreadMin, spreadMax, burstTimer / spreadThreshold); //Current Spread lerps between spreadMin and spreadMax by burstTimer (increases per shot)
int i = 0;
totalShotDamage = 0; //Buckshot sends 8 rays down the range. totalShotDamage gets total damage done by all rays. Needed for displaying damage text
while (i < bulletCount) //Repeats Shooting Vector for bulletCount amount (needed for buckshot)
{
Vector3 shootDirection = shootOrigin.transform.forward; //Shoot Vector 100% accuracy
shootDirection += shootOrigin.transform.right * (Random.Range(-spreadAmount, spreadAmount)); //Randomizes Vector horizontally, reduces accuracy
shootDirection += shootOrigin.transform.up * (Random.Range(-spreadAmount, spreadAmount)); //Randomizes Vector Vectically, reduces accuracy
Ray ray = new Ray(shootOrigin.transform.position, shootDirection); //Ray from Shoot vector
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, 2000, shootLayerMask)) //Sets range of gun & sends ray
{
Vector3 hitPoint = hitInfo.point; //Point of impact with any object
GameObject go = hitInfo.collider.gameObject; //GameObject of impacted Object
string targetTag = hitInfo.collider.gameObject.tag; //Tag of GameObject of impacted Object
addHitParticleEffects(targetTag, hitInfo, enableBulletholes); //Add hitparticle effects based on Tag (IMPACTmaterial)
damageEnemy(targetTag, hitInfo, damage, damageRollOff); //Damage enemy
}
i++; //total bullet count (needed for buckshot)
}
2) Terrain Inspector Settings
3) LOD Settings
There are no LOD Settings (yet). Individual Planes of the whole Terrain and objects on top of it simply pop in and out of existence depending on the Players position.