Can you change the size of an object based on a world scale?

I would like to change the object’s size based on a world scale.
The object is rotating and when it hits the floor I’d like it to have the same deform animation.
But the only way how it works is with a local scale which breaks the animation.
Is it possible?

No need for changing your object’s size based on the updated, deformed animation’s collision bounds.
You can update your object’s physics shape after the deformed animation has started or ended with:



new_scale = 0.5
own.scaling = [new_scale, new_scale, new_scale]

Interesting, but this is not what I’m looking for.
What I’m working on is a simple animation with object scaling in python.
This object is without a collision so there is no need for a mesh update.
It’s just when I rotate the object, the z scale applies only locally and not based on the world scale.

I think I’ve tried that one before, it applies local scale.

ok - look here - if you use upbge version 0.2.5 else if look API for upbge 0.3.0

You can sync your animation to your world scale:

import bge

def main(self):
    self.owner.playAction("Action", 0, int(self.owner.worldScale[0]))

This is limited to using only one world scale axis of your choice, but object scale should always be proportional anyhow, so that shouldn’t be too much of an issue.

This sounds like you’re using KX_GameObject.localScale or KX_GameObject.scale insead of KX_GameObject.worldScale.

If none of these possible solutions help, please consider sharing a blend so we can see what you’re trying to accomplish visually.

Thank you for your suggestions.
I’m making an “animation” through python script with scaling.
but when I use worldScale for scaling, this happens:

AttributeError: KX_GameObject.worldScale is read-only

it says:
The object’s scaling factor. [sx, sy, sz] On write: local scaling, on read: world scaling
I’ve tried this before, it just scales the object locally.

Are you applying world scale this way?

All scale axises

import bge

def main(self):

  self.owner.worldScale = [1,1,1]

A single scale axis

import bge

def main(self):

  self.owner.worldScale.x = 1

I have tried both.

self.owner.worldScale = [1,1,1]

applied the localScale, because I wanted to apply the Z on worldScale which when I’ve rotated the object, the z scale was applied locally. Therefore for this example, the scale occurred on the x-axis because the object was rotated.

self.owner.worldScale.x = 1

gave me this error:

AttributeError: KX_GameObject.worldScale is read-only

Maybe try this instead then.


Could you share a part of your actual code?

Thank you, I’ve tried that one too, it still applies the local scaling.
I’ll show an example of what I mean.

Here you can see when the first object reaches the pallet, the scale animation is applied correctly how I wanted but with the second one when I rotate it, it’s applied locally.
And I’ve tried all the suggestions.

It looks like something is triggering your second purple cube’s collision detection system before it hits the ground. World scale works for me on my end even when my cube is rotated.

I guess it doesn’t work in BGE, since I use BGE and not UPBGE
I have tried the exact same code but it just tells this:

AttributeError: KX_GameObject.worldScale is read-only

What type of object is the entity that you’re applying the scale to - a mesh?

It’s a no-collision mesh.

Are you still using Blender 2.49.


I’m using Blender 2.79b