private void AlignToTerrain(Transform toAlign, float distanceFromTerrain = 0) { var terrainHit = TerrainCaster.TerrainCast(toAlign.position, CoastlineTerrain); toAlign.rotation = Quaternion.FromToRotation(Vector3.up, terrainHit.normal); toAlign.position = terrainHit.point + terrainHit.normal * distanceFromTerrain; }
public void PlantFakeTree(ZoneProfile zoneProfile, GameObject tree, Spacey.IWorldly treePoint, float treeScale) { var treeRandomizedRotation = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.up); var treeRot = TerrainCaster.SampleRotation(treePoint, CoastlineTerrain) * treeRandomizedRotation; var treeInstance = Instantiate(tree, treePoint.Worldly, treeRot, GetZoneTreeHolder(zoneProfile)); treeInstance.transform.localScale = Vector3.one * treeScale; }
private void ResetTerrainHit() { this._terrainHit = new Lazy <RaycastHit>(() => TerrainCaster.TerrainCast(Worldly, WorldTerrain)); }