Post Reply 
 
Thread Rating:
  • 5 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Unified" missile script + Dual-/multi-profile missile script [2016-10-30]
2017-01-14, 12:25 PM (This post was last modified: 2017-01-14 12:26 PM by Eon.)
Post: #61
RE: "Unified" missile script + Dual-/multi-profile missile script [2016-10-30]
Is anyone else having issues with lua guided missiles seeming to intentionally avoid air targets? I've tried using several different guidance scripts but it's always the same issue - the missiles trail behind the target until they get within about 10 meters, then just as they are about to hit they divert somewhere around it and start flying next to the target, or try to turn around and hit it again.

I suspected it was an issue with my detection systems - but I turned on full automatic detection accuracy and my missiles still flew around rather than into air targets. I also tried tinkering with the missile itself, to no avail.

They used to work fine about 6 months ago - consistently hitting everything but now they struggle to hit even Drakes!

I've attached the blueprint of the aircraft I've been trying to get it to work with. The missile guidance lua box is located behind the left-hand side of the cockpit (looking backwards). The code that's in there right now is from this thread but I've also tried using several different presets from here and this guidance script which I honestly don't know where it came from:

Code:
--Side Functions
function Speed(vel)
   return math.sqrt(vel.x^2 + vel.y^2 + vel.z^2)
end

function Distance(a,b)
   return math.sqrt((a.x - b.x)^2 + (a.y - b.y)^2 + (a.z - b.z)^2)
end



missileDictionary = {}
missileIndex = {}

currentTarget
= {}
currentTarget.pos = false

currentTarget.id = false
currentTarget.maxSpeed = 0


function Update(I)

  targetInfo = I:GetTargetInfo(0, 0)


  if(targetInfo.Valid==true) then
    
    if (currentTarget.id ~= targetInfo.Id) then
      currentTarget = {}
      currentTarget.pos = false
      currentTarget.id = targetInfo.Id
      currentTarget.maxSpeed = 0
    end

   TS = Speed(targetInfo.Velocity)
    if ( currentTarget.maxSpeed < TS ) then
      currentTarget.maxSpeed = TS
    end

      for t=0,I:GetLuaTransceiverCount() do
        for m=0,I:GetLuaControlledMissileCount(t) do
        
          missileInfo = I:GetLuaControlledMissileInfo(t, m)
          P = targetInfo.AimPointPosition

          V = targetInfo.Velocity
          D = Distance(missileInfo.Position, targetInfo.AimPointPosition)
          S = Speed(targetInfo.Velocity-missileInfo.Velocity)
          Time =  D/S

        
          if (P.y < 10 and D>250) then
             P=P+Vector3(0,200,0)
          end
          if (P.y > 10 and D>150  and Speed(targetInfo.Velocity) < 20 ) then
             P=P+Vector3(0,10,0)
          end
          if (D<250 and Speed(targetInfo.Velocity) > 30 ) then
               x =  ((324324+targetInfo.Id + missileInfo.Id) * 53419234 % 3215) / 3215.0 -0.5
               y =  ((934234+targetInfo.Id + missileInfo.Id) * 93492344 % 2365) / 2365.0 -0.5
               z =  ((674577+targetInfo.Id + missileInfo.Id) * 33439431 % 1345) / 1345.0 -0.5
               angleOfAttack =  Vector3(x,y,z)
               P = P + V * Time
               if(Time>2) then
                   P = P + angleOfAttack * S * (Time-1)
               end
          else
               P = P + V*Time
          end

          
        

          I:SetLuaControlledMissileAimPoint(t ,m ,P.x ,P.y ,P.z)

        end
      end

    

    end
  
end


Attached File(s)
.blueprint  F-61 Peregrine Falcon.blueprint (Size: 112.94 KB / Downloads: 3)

[Image: CU6kuFB.png]
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)