Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Check if the rotor blades are hitting things.
- function ENT:CheckRotorClearance( dt, parent )
- -- The trace will use a spinning angle separate from the model
- self.traceAngle = ( self.traceAngle + dt * 1600 ) % 360
- local ang = parent:LocalToWorldAngles( self.baseAngles )
- ang:RotateAroundAxis( ang[self.spinAxis]( ang ), self.traceAngle )
- local dir = self.spinAxis == "Forward" and ang:Right() or ang:Forward()
- local data = self.traceData
- local origin = self:GetPos()
- -- Trace towards the angle direction
- data.start = origin
- data.endpos = origin + dir * self.radius
- if IsValid(self:GetParent():GetDriver()) then -- copter & driver
- data.filter = {self:GetParent():GetDriver(),self:GetParent()}
- else
- data.filter = self:GetParent() -- copter
- end
- if self.isDebugging then
- debugoverlay.Line( data.start, data.endpos, 0.05, Color( 255, 0, 0 ), true )
- end
- local tr = TraceHull( data )
- if tr.Hit and not tr.HitSky and not tr.HitNoDraw and tr.HitTexture ~= "**empty**" then
- self:OnRotorHit( tr.Entity, tr.HitPos, origin )
- return
- end
- -- Another trace on the opposite direction
- data.endpos = origin - dir * self.radius
- tr = TraceHull( data )
- if tr.Hit and not tr.HitSky and not tr.HitNoDraw and tr.HitTexture ~= "**empty**" then
- self:OnRotorHit( tr.Entity, tr.HitPos, origin )
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement