GetViewRange

This function gets an entity's view range.

Syntax

Returns

Returns the entity view range. This will be one of the following values:

Example

entity = {}

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
camera:Move(0,2,0)
camera:SetRotation(45,0,0)
camera:Move(0,0,-8)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

local box = Model:Box()

for i=0, 100 do
entity[0] = box:Instance()
entity[0]:SetPosition(-5,1,i*10.0)
entity[0]:SetViewRange(Entity.NearViewRange)
entity[0]:SetColor(Math:Random(),Math:Random(),Math:Random())
end

for i=0, 100 do

entity[1] = box:Instance()
entity[1]:SetPosition(0,1,i*10.0)
entity[1]:SetViewRange(Entity.MediumViewRange)
entity[1]:SetColor(Math:Random(),Math:Random(),Math:Random())
end

for i=0, 100 do

entity[2] = box:Instance()
entity[2]:SetPosition(5,1,i*10.0)
entity[2]:SetViewRange(Entity.FarViewRange)
entity[2]:SetColor(Math:Random(),Math:Random(),Math:Random())
end

box:Release()

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

context:SetBlendMode(Blend.Alpha)
context:DrawText("Left row view range:"..entity[0]:GetViewRange(),2,2)
context:DrawText("Center row view range:"..entity[1]:GetViewRange(),2,22)
context:DrawText("Right row view range:"..entity[2]:GetViewRange(),2,42)

context:Sync()
end