Difference between revisions of "DCS func setPoint"

From DCS World Wiki - Hoggitworld.com
Line 48: Line 48:
 
             ray:destroy()
 
             ray:destroy()
 
         end
 
         end
 
 
     end
 
     end
 
     timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)
 
     timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)

Revision as of 00:45, 1 November 2021

Scripting Root

Envrioment: Mission Scripting
Function: setPoint Added with: 1.2.6
Member Of: Spot
Syntax: function Spot.setPoint(Class Self , table vec3 )
Description: Sets the destination point from which the source of the spot is drawn toward.


Return Value: function
Return Example: none
Examples: The following will create a laser point and update the point of the ray every half a second. Once the target unit is destroyed it will remove the laser.
   local jtac = Unit.getByName('jtacBob')
   local target = Unit.getByName('BMPAirDefenseSystemGroup1_unit1')
   local ray = Spot.createLaser(jtac, {x = 0, y = 1, z = 0}, target:getPoint(), 1337)
   local function updateRay()
       if target:getLife() > 0 then
           ray:setPoint(target:getPoint())
           timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)
       else
           ray:destroy()
       end
   end
   timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)
Related Functions: Spot Functions: createLaser. createInfraRed, destroy, getCategory, getPoint, setPoint, getCode, setCode
Notes: