Assets/Examples/Scripts/TerrainDeformer.cs
/// <summary>
/// Tests if the player is in the way of deforming and edits the terrain if the player is not.
/// </summary>
/// <param name="addTerrain">Should terrain be added or removed</param>
Tests if the player is in the way of deforming and edits the terrain if the player is not.
Tests if the player is in the way of deforming and edits the terrain if the player is not .
private void RaycastToTerrain(bool addTerrain)
        {
            var ray = new Ray(playerCamera.position, playerCamera.forward);
            if (!Physics.Raycast(ray, out RaycastHit hit, maxReachDistance)) { return; }
            Vector3 hitPoint = hit.point;
            if (addTerrain)
            {
                Collider[] hits = Physics.OverlapSphere(hitPoint, deformRange / 2f * 0.8f);
                if (hits.Any(h => h.CompareTag("Player"))) { return; }
            }
            EditTerrain(hitPoint, addTerrain, deformSpeed, deformRange);
        }
private void RaycastToTerrain ( bool addTerrain ) { var ray = new Ray ( playerCamera . position , playerCamera . forward ) ; if ( ! Physics . Raycast ( ray , out RaycastHit hit , maxReachDistance ) ) { return ; } Vector3 hitPoint = hit . point ; if ( addTerrain ) { Collider [ ] hits = Physics . OverlapSphere ( hitPoint , deformRange / 2f * 0.8f ) ; if ( hits . Any ( h => h . CompareTag ( " " ) ) ) { return ; } } EditTerrain ( hitPoint , addTerrain , deformSpeed , deformRange ) ; }
Tests if the player is in the way of deforming and edits the terrain if the player is not.
Tests if the player is in the way of deforming and edits the terrain if the player is not .
addTerrain
bool
Should terrain be added or removed
Should terrain be added or removed