Joyride Posted October 15, 2013 Posted October 15, 2013 Has anyone been able to generate a continuous beam onto a moving target? I am assuming that Spot.setPoint function would update the laser spot, but couldn't get it to work. I did a workaround (see below) to end and restart the laser every second, to keep the beam updating onto the moving target, but it's jumpy and difficult to lock as SPI from the A-10 TGP. -- function to generate IR and laser from Origin Group Lead to Target Group Lead function SparkleLase(OriginGroupName, TargetGroupName, LCode) local OriginGroup, TargetGroup = Group.getByName(OriginGroupName), Group.getByName(TargetGroupName) local OriginUnits, TargetUnits = OriginGroup:getUnits(), TargetGroup:getUnits() local spots = {} local TargetVec3 = TargetUnits[1]:getPoint() local TargetAdjVec3 = {x = TargetVec3.x, y = TargetVec3.y + 2, z = TargetVec3.z} local status, result = pcall(function () spots['Sparkle'] = Spot.createInfraRed(OriginUnits[1], {x = 0, y = 2, z = 0}, TargetAdjVec3) spots['Laser'] = Spot.createLaser(OriginUnits[1], {x = 0, y = 2, z = 0}, TargetAdjVec3, LCode) return spots end) if not status then env.error('ERROR: ' .. assert(result), false) else if result.Sparkle then local Sparkle = result.Sparkle function KillSparkle() Spot.destroy(Sparkle) end function UpdateSparkleLase() KillSparkle() KillLase() SparkleLase(OriginGroupName, TargetGroupName, LCode) end timer.scheduleFunction(UpdateSparkleLase, nil, timer.getTime() + 1) end if result.Laser then local Laser = result.Laser function KillLase() Spot.destroy(Laser) end end end end
Grimes Posted October 15, 2013 Posted October 15, 2013 Run it at least 10 times a second to smooth it out. But I think the continued creation and destruction of the laser might cause the avionics to have a hard time gaining lock. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Joyride Posted October 15, 2013 Author Posted October 15, 2013 Thanks, Grimes. Processing on a 0.1 sec delay definitely helps. Not perfect, but usable for now.
Recommended Posts