Adjusting Object Size in-game

Hey guys,
Im new here and I would like to point out I have no experience in Python scripting. Anyway, I am making a game which requires the player to collect powerups around the level which when picked up alter the physical properties of the character, for example become bigger or smaller or change in mass. How would I go about doing this?
Any help would be appreciated.

Cheers.

There’s a python function for changing mass.

As for size, you could have a size IPO and set an IPO actuator to the value of a property. But until IPO actuators can act on just a single IPO curve it’ll play all the IPO curves at once.

You could replace the object with a bigger version too for size.

it’s called object.setMass(newmass)

I Scale IPO should get the job done as mentioned. Have it to play by property and every time you collect and object the property is increased. If you are using IPOs for say rotating the object I suggest you use an empty or a box that rotates and move and parent the scalable player character to it

thanks guys. For some reason I expected blender to be able to modify this easily using actuators. I thought it was a pretty simple concept that should be done easily

Nothings easy. Python is needed for it. It’s a very simple script though.

Okay, I don’t really understand the IPO way but the way that involves switching character objects to different sizes sounds logical. Is somebody able to demonstrate how a cube could be affected by powerups with a .blend file? Or can someone direct me to a link that explains this?

:eyebrowlift2:

well, actually you CAN change the size via python without IPOs. I wrote this the other day.

import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()

size = 5

ori = own.getOrientation()

own.setOrientation([[ori[0][0]*size,ori[0][1]*size,ori[0][2]*size],
		[ori[1][0]*size,ori[1][1]*size,ori[1][2]*size],
		[ori[2][0]*size,ori[2][1]*size,ori[2][2]*size]])

‘size’ is the number it is scaled by. In this example, the mesh will become 5 times bigger every time the script is run.

I will try that now. Thanks heaps!!!

then do this:


import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()

size = 5

ori = own.getOrientation()

own.setOrientation([[ori[0][0]*size,ori[0][1]*size,ori[0][2]*size],
        [ori[1][0]*size,ori[1][1]*size,ori[1][2]*size],

        [ori[2][0]*size,ori[2][1]*size,ori[2][2]*size]])

own.setMass(newmassamount)

This matrix method has one inconvenient: it does not scale the physic representation of the object.
It’s better and simpler to use


own.scaling = [size,size,size]

Generally speaking, the orientation matrix should always be a pure rotation matrix.

own.setMass(newmassamount) it does not work! “Attribute Error setMass”