View Single Post
11-24-19, 12:12 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Something like:
Lua Code:
  1. local units = {}
  2. units.player = CreateFrame("PlayerModel", nil, UIParent)
  3. units.player:SetSize(150, 200)
  4. units.player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  5. units.player:SetUnit("player")
  6. units.player:SetCamera(2)
  7. units.player:SetFacing(30)
  8. units.player:RefreshCamera()
  9. units.player:Show()
  10.  
  11. units.target = CreateFrame("PlayerModel", nil, UIParent)
  12. units.target:SetSize(150, 200)
  13. units.target:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  14. units.target:SetUnit("target")
  15. units.target:SetCamera(2)
  16. units.target:RefreshCamera()
  17. units.target:Show()
  18.  
  19. units.target:SetScript("OnEvent", function(self, event, ...)
  20.     if event == "PLAYER_TARGET_CHANGED" then
  21.         if UnitExists("target") then
  22.             self:SetUnit("target")
  23.             self:Show()
  24.         else
  25.             self:Hide()
  26.         end
  27.         return
  28.     end
  29.     local unit = ...
  30.     local unitframe = units[unit]
  31.     if unitframe then
  32.         unitframe:SetUnit(unit)
  33.     end
  34. end)
  35.  
  36. units.target:RegisterEvent("UNIT_MODEL_CHANGED")
  37. units.target:RegisterEvent("UNIT_PORTRAIT_UPDATE")
  38. units.target:RegisterEvent("PLAYER_TARGET_CHANGED")
The target frame traps the events for both models and checks against the unit parameter (for the UNIT_ events) for which one is being effected by the event then looks up the units table to find if and which frame to update.

You can use the model:SetPortraitZoom() and SetPosition() methods zoom/move the model within the frame.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-24-19 at 12:23 AM.
  Reply With Quote