I compared the times it takes to cast 1000 rays with different methods. With timescaling turned off, 1000 CastMORays took MSPF from 4 to 15-180 in tutorial bunker. With CastObstacleRay MSPF was between 15 and 200. CastStrengthRay went as high as 200-350 milliseconds per frame. I used the following script attached to an actor:
Code:
function Create(self)
self.state = 1
self.uselessvector = Vector(0,0)
end
function Update(self)
if self:GetController():IsState(8) then
self.state = self.state + 1
if self.state > 4 then
self.state = 1
end
end
for i=1 , 1000 , 1 do
if self.state == 1 then
end
if self.state == 2 then
self.MOID = SceneMan:CastMORay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , 0 , 0 , false , 0)
end
if self.state == 3 then
self.dist = SceneMan:CastObstacleRay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , self.uselessvector , self.uselessvector , 0 , 0 , 0)
end
if self.state == 4 then
self.dist = SceneMan:CastStrengthRay(self.Pos,Vector(200 * math.cos(self:GetAimAngle(false)) , -200 * math.sin(self:GetAimAngle(false))) , 1500 , self.uselessvector , 0 , 0 , true)
end
end
end