Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class HeightDisabler : MonoBehaviour
- {
- public float MaxHeight;
- private MeshRenderer _renderer;
- void Start()
- {
- _renderer = gameObject.GetComponent<MeshRenderer>();
- }
- void Update()
- {
- var ray = new Ray(transform.position, Vector3.down);
- this._renderer.enabled = !Physics.Raycast(ray, MaxHeight);
- }
- }
Add Comment
Please, Sign In to add comment