ent.Create in weapons with WAC Aircraft?


function SWEP:PrimaryAttack()
   self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
   self:PlaneDrop()
end

function SWEP:PlaneDrop()
   if SERVER then
      
      local ply = self.Owner
      if not IsValid(ply) then return end

      local helicopter = ents.Create( "wac_hc_ah1z_viper" )
      if ( IsValid(helicopter) ) then
         local trace = ply:GetEyeTrace()
      local vector = trace.HitPos
       vector.z = vector.z + 20
         helicopter:SetPos( vector )
         helicopter:SetModel("models/bf2/helicopters/mil mi-28/mi28_b.mdl")
         helicopter:SetOwner(ply)
         helicopter:Spawn()
         helicopter:Activate()
      end
   end
end

Hello, I have been combining and adding tidbits of code in an attempt to make a weapon that can spawn a WAC Aircraft helicopter. However, I am able to walk through it and not use any of the WAC controls. When I use ulx ent however, it is fully usable with all controls.

I believe off of reading off of other notes that I need to set a Keyvalue such as a script like “scripts/vehicles/airboat.txt” (for airboats), however, what would that be for a custom script like WAC?

Thanks in advance!

That’s because you’re doing SetOwner(ply); SetOwner disables all collision with the player you declare it to.