View Single Post
11-22-07, 07:28 AM   #2
Teif
A Deviate Faerie Dragon
Join Date: May 2006
Posts: 12
One thing you can do instead of using the OnUpdate method is to register the event PLAYER_TARGET_CHANGED with your AddOn. This event will trigger everytime your target changes, also when your target is lost.

you can then do a check for a target when this event is fired, and if a target exists, do the update.

Code:
function MyAddOn_OnEvent(frame, event, ...)
   if (event == "PLAYER_TARGET_CHANGED") then
      if (UnitExists("target")) then
        
         -- The event has been triggered, and we have a target
         -- update your PlayerModel instance here

         PlayerModel:SetUnit("target");
      else
    
         -- do whatever you wanted to do when there's no target
         -- (hiding the frame, showing an empty window, etc) ...

      end
   end
end
Hope this helps.
  Reply With Quote