Search Unity

Updating outdated scripts (Creating a hole in Unity Terrain)

Discussion in 'Scripting' started by Iduh, Jan 30, 2019.

  1. Iduh

    Iduh

    Joined:
    Jan 30, 2019
    Posts:
    2
    Hey, I need help converting these old scripts (All the way from 2012 and from this blog) to work with a newer version of unity. These scripts are used to make holes in the Unity terrain but don't work that great with a semi-new version of unity (2017.3).

    Script used for disabling collider on terrain etc. :
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TerrainHole : MonoBehaviour {
    5.  
    6. public Collider player;
    7. public TerrainCollider tCollider;
    8.  
    9. void OnTriggerEnter (Collider c) {
    10.   if (c.tag == "Player") {
    11.      Physics.IgnoreCollision(player, tCollider, true);
    12.   }
    13. }
    14.  
    15. void OnTriggerExit (Collider c) {
    16.   if (c.tag == "Player") {
    17.      Physics.IgnoreCollision(player, tCollider, false);
    18.   }
    19. }
    20.  
    21. }
    Here is the code for the shader used for making an object transparent so that you can see through the terrain (for more details click here):
    Code (CSharp):
    1. Shader "Depth Mask" {
    2.   SubShader {
    3.     Tags {"Queue" = "Geometry+10" }
    4.     Lighting Off
    5.     ZTest LEqual
    6.     ZWrite On
    7.     ColorMask 0
    8.     Pass {}
    9.   }
    10. }