View Single Post
03-28-15, 11:30 AM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Need Help with PlayerModel!

Hi, I have been trying to understand how PlayerModel's work and I get very strange behaviours.

This is my first attempt code:
Lua Code:
  1. f.model = CreateFrame("PlayerModel", nil, f)
  2. f.model:SetSize(600, 800)
  3. f.model:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 100, -100)
  4. f.model:SetUnit("player")
  5. f.model:SetPosition(0, 0, -0.75)
  6. f.model:SetCustomCamera(1)
  7. f.model:SetCameraPosition(2.8, -1, 0.4)

But this causes the Lua error below which I do not know why:
Code:
<unnamed> is not using a custom camera.
I set a custom camera only because without a custom camera, the positioning and size etc kept getting changed and I have no clue why. I then changed the code to be used in an "OnShow" event like this:

Lua Code:
  1. f.model = CreateFrame("PlayerModel", nil, f)
  2. f.model:SetSize(600, 800)
  3. f.model:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 100, -100)
  4. f.model:SetUnit("player")                  
  5.  
  6. f.model:SetScript("OnShow", function(self)
  7.     self:SetPosition(0, 0, -0.75)
  8.     self:SetCustomCamera(1)
  9.     self:SetCameraPosition(2.8, -1, 0.4)
  10. end)

This removed the strange Lua error but I get the same problem with the camera being altered some how. The first time the model is shown, the positioning is completely wrong but GetCameraPosition() shows the right numbers. The 2nd time is gets shown, it displays correctly and the number with GetCameraPosition() are the same as the first time.

Obviously I must be not understanding something important?
That is all the code as I'm just getting started.

Can anyone help me?
Thank you!

EDIT: Also even without using any custom cameras, altering any positions, or distance values, the first time it shows is always very different to the 2nd time it shows..

Last edited by Mayron : 03-28-15 at 11:36 AM.
  Reply With Quote