WoWInterface - View Single Post - PlayerModel:SetTransform bug
View Single Post
09-22-19, 11:47 AM   #5
A Murloc Raider
Join Date: Mar 2019
Posts: 4
Thanks for the responses, was a huge help. You were both right about needing to delay calling SetTransform after setting the model. Went with a timer with a duration of 0.01, did the trick just fine. I also discovered that SetTransform needs to be called whenever the model is changed with SetModel. The transform values seem to get reset. Something else I noticed is that there might be an issue with using frame:Show() and frame:SetTransform() at the same time. Didn't test it further since a timer of 0.01 updates faster than anyone would notice, but I thought I'd still mention it in case someone comes across this thread in the future.

d87: could you provide some more insight about it being different based on the client resolution? What kind of differences are there? If you know of a thread or something where SetTransform's quirks are discussed that'd be awesome.

LudiusMaximus: I feel your pain. Not sure why SetTransform isn't on the wiki yet. I discovered it while digging around WeakAura's files to figure out what they were doing since I was having so many problems myself. I don't see them doing any of the timing stuff that I ended up having to do, but maybe they're just doing it in a different part of the code I didn't look at. Here's the actual SetTransform implementation I'm using; might give you some insight:

local offset = (0.205 * size) / 1000

    offset, offset, 0,
    rad(rotation.X), rad(rotation.Y), rad(rotation.Z),
    scale / 1000)
The reason I'm setting offset the way I am is that the models seem to appear in the bottom left corner by default. Through testing I found that 0.205 * size puts the model in the center (or really close to it). If the frame's width and height is different then you'd need to calculate each individually. I'm still testing though, so I'm not sure it'll work for every model. Also, scale is a value between 1-1000. Just feel it's more convenient to work with whole numbers instead of decimals.

Last edited by Alaror : 09-22-19 at 12:04 PM.
  Reply With Quote