Re: Determining whether something is underground
If you wanted to find if something just doesn't have line of sight to the air as a way of measuring "underground-ness", theoretically you could also do something like
Code:
if SceneMan:CastStrengthSumRay(self.Pos,SceneMan:MovePointToGround(Vector(self.Pos.X,0),1,1),0,128) >= 5 then
--You are under at least 5 strength units worth of terrain (admittedly not much, you could adjust that), do stuff
else
--You are under only a small bit of scrap or nothing, aka above ground, do other stuff
end
Haven't tested it, but this would likely work with overhangs and/or tall ceilings. Would still have the issue of only being a single ray and therefore not noting if you're in say a doorway.
Would also probably be terrible for deep levels, so you might want to do something like this instead:
Code:
local foundGround = SceneMan:MovePointToGround(Vector(self.Pos.X,0,1);
if SceneMan:GetShortestDistance(self.Pos,foundGround,false) > 800 then
if SceneMan:CastStrengthSumRay(self.Pos,foundGround,1,1),0,128) >= 5 then
--You are under at least 5 strength units worth of terrain (admittedly not much, you could adjust that), do stuff
else
--You are under only a small bit of scrap or nothing, aka above ground, do other stuff
end
else
--Use one of the other ways to check if underground I guess, or maybe do a check not from the sky (so you'd do SceneMan:MovePointToGround(Vector(self.Pos.X,math.min(self.Pos.Y + 500,SceneMan.SceneHeight/2),1) or something like that)
end
Maybe this is overcomplicating things though..