UPBGE Matrix Transforms seem to be malfunctioning?

For some reason the Matrix Transforms are not being applied correctly through python in the UPBGE. This is this issue I am facing:

import bge
from mathutils import Matrix

def main(cont):
own = cont.owner
sens = cont.sensors[‘Keyboard’]

if sens.positive:
    newcoords = Matrix(((.75,0,0,0),(0,.75,0,0),(0,0,.75,0),(0,0,0,1)))
    own.worldTransform = newcoords
    print('test')

else:
    print(own.worldTransform)

When applied, this should scale down an object by 75%, however for some reason, in UPBGE it applies the scaling twice? Resulting in a scale-down of 5625%.

Attached is the example Blender File, open in up in UPBGE 2.5 and you will see transform matrix printed out into the console not as .75 but as .5625.

Am I missing a simple solution here?

You have double execution

Make sure 'tap" is checked in the sensor

1 Like

Unfortunately @BluePrintRandom in this specific instance, this appears to not be the case. This, let’s call it an ‘error’ happens if Tap is enabled or not.

My suspicion at this point, is that I have found myself a bug.

Did you test the file? I have tried whacking away at it with everything, nothing seems to help.

It’s not double execution as you can see from the code it only scales on sens.positive(key first pressed) and prints the world transform when not positive(key is released).

I don’t use upbge but it works as expected in 2.79b so this must be something introduced in upbge.

Workaround(this probably isn’t what you want but here’s this anyway):
If you only want to scale an object, use object.localScale

if sens.positive:
    owner.localScale *= 0.75
else:
    print(own.worldTransform) # or maybe you just need own.worldScale
1 Like

I get this

it appears to be working correct for me after I enabled tap mode-

when is your build from and what platform?

1 Like

Yeah setting the scale directly in this way works ok-- however the matrix transforms, in this specific case, need to be my method of applying the transformations.

This is mainly because of performance limitations.

I am using 2.5a - on windows 7. This looks more and more like a bug to me now.

oh I am on 0.3.0

I did not test in 0.2.5

This is what I am getting:

press K a few times

does it get smaller and smaller?

1 Like

nope stays the same size

You can even calculate the error. It appears to be delivering the adjugated() matrix as the local matrix.

so if you do this, it delivers a .75 matrix scaling, but you can’t apply this to the object.localTransform:

correct = newcoords.adjugated()*newcoords.inverted()

I can confirm that it works in 3.0

@lordloki_reloaded it appears we have a smol regression in 2.5 release

1 Like

Is this something that I can fix? Should I report it as a bug?

yeah I think it’s a bug - and loki probably already has a way to fix it
I pinged him - but you can open a report too if you want.

1 Like

Thanks @BluePrintRandom, I have posted the bug on GitHub.
This seems like a pretty integral feature that would benefit me and a lot of other users as well.

I posted it here under issues:

Thanks for the help!