Created
April 26, 2019 17:27
-
-
Save thimenesup/0f039e86a2e50661cb054b4f068e1f1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends MeshInstance | |
export var lod_distance = 15 | |
export(Array,Mesh) var meshes | |
func _notification(what): | |
if what == NOTIFICATION_VISIBILITY_CHANGED: | |
set_process(is_visible_in_tree()) | |
func _process(delta): | |
var camera = get_viewport().get_camera() | |
var i = translation.distance_to(camera.translation) / lod_distance | |
i = int(clamp(i,0,meshes.size()-1)) | |
mesh = meshes[i] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment