1. Hello!

    I have tried for a couple of days to figure out my error, but cannot. All I want to do is populate a PlayerModel with the player character. I'd appreciate any pointers in the right direction.

    This is what I've done. It fails at 'PlayerModel1:SetUnit("player");':

    frame.lua

     function myFrame_OnLoad(self)
        self:RegisterEvent("UNIT_MODEL_CHANGED");
     end
    
     function myFrame_OnEvent(self, event, ...)
        local unit = ...;
        if ( event == "UNIT_MODEL_CHANGED" and unit == "player" ) then
            myPlayerModel_Update();
            return;
        end
     end
    
     function myPlayerModel_Update()
     -- Message: Attempt to call method 'SetUnit'(a nil value)
        PlayerModel1:SetUnit("player");
     end
    

    frame.xml

     <Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
        <Script file="Frame.lua" />
        <Frame name="Frame1" parent="UIParent" toplevel="true" enableMouse="true">
            <Size>
                <AbsDimension x="200" y="200" />
            </Size>
            <Anchors>
                <Anchor point="CENTER" />
            </Anchors>
            <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
                <BackgroundInsets>
                    <AbsInset left="11" right="12" top="12" bottom="11" />
                </BackgroundInsets>
                <TileSize>
                    <AbsValue val="32" />
                </TileSize>
                <EdgeSize>
                    <AbsValue val="32" />
                </EdgeSize>
            </Backdrop>
            <Frames>
                <Model xsi:type="PlayerModel" name="PlayerModel1">
                    <Size>
                        <AbsDimension x="157" y="155" />
                    </Size>
                    <Anchors>
                        <Anchor point="TOPLEFT">
                            <Offset x="22" y="-24" />
                        </Anchor>
                    </Anchors>
                    <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
                        <BackgroundInsets>
                            <AbsInset left="11" right="12" top="12" bottom="11" />
                        </BackgroundInsets>
                        <TileSize>
                            <AbsValue val="32" />
                        </TileSize>
                        <EdgeSize>
                            <AbsValue val="32" />
                        </EdgeSize>
                    </Backdrop>
                </Model>
            </Frames>
            <Scripts>
                <OnLoad>myFrame_OnLoad(self)</OnLoad>
                <OnEvent>myFrame_OnEvent(self, event, ...)</OnEvent>
            </Scripts>
        </Frame>
     </Ui>
    
  2. You are creating a model and using xsi:type="PlayerModel". That's not how you instantiate a PlayerModel. Use the <PlayerModel> tag in order to accomplish this, instead of <Model>.

  3. Thank you, James. That was indeed the problem and the correction that you listed worked perfectly.

    The syntax that I used was generated automatically using AddOn Studio. Even after I made the correction, it changed the correction back to its original syntax once I hit the save button. So, I opted to make the change in Notepad instead and bypass AddoOn Studio.

    I just became interested in WOW programming and ordered your book after finding this website. I look forward to its arrival. Thanks again for sharing your talents with me and the community-at-large.

  4. Glad I could help, please let me know if I can be of further assistance.