Advertisement
Kurome76

Glide Rotor Clearance Fix

Mar 3rd, 2025
94
0
29 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | Fixit | 0 0
  1. --- Check if the rotor blades are hitting things.
  2. function ENT:CheckRotorClearance( dt, parent )
  3.     -- The trace will use a spinning angle separate from the model
  4.     self.traceAngle = ( self.traceAngle + dt * 1600 ) % 360
  5.  
  6.     local ang = parent:LocalToWorldAngles( self.baseAngles )
  7.     ang:RotateAroundAxis( ang[self.spinAxis]( ang ), self.traceAngle )
  8.  
  9.     local dir = self.spinAxis == "Forward" and ang:Right() or ang:Forward()
  10.     local data = self.traceData
  11.     local origin = self:GetPos()
  12.    
  13.     -- Trace towards the angle direction
  14.     data.start = origin
  15.     data.endpos = origin + dir * self.radius
  16.    
  17.     if IsValid(self:GetParent():GetDriver()) then -- copter & driver
  18.         data.filter = {self:GetParent():GetDriver(),self:GetParent()}
  19.     else
  20.         data.filter = self:GetParent() -- copter
  21.     end
  22.  
  23.     if self.isDebugging then
  24.         debugoverlay.Line( data.start, data.endpos, 0.05, Color( 255, 0, 0 ), true )
  25.     end
  26.  
  27.     local tr = TraceHull( data )
  28.  
  29.     if tr.Hit and not tr.HitSky and not tr.HitNoDraw and tr.HitTexture ~= "**empty**" then
  30.         self:OnRotorHit( tr.Entity, tr.HitPos, origin )
  31.         return
  32.     end
  33.  
  34.     -- Another trace on the opposite direction
  35.     data.endpos = origin - dir * self.radius
  36.  
  37.     tr = TraceHull( data )
  38.  
  39.     if tr.Hit and not tr.HitSky and not tr.HitNoDraw and tr.HitTexture ~= "**empty**" then
  40.         self:OnRotorHit( tr.Entity, tr.HitPos, origin )
  41.         return
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement