bgui to modify objects

Hi. How can I modify an object, for example, its scale, from a bgui’s buttons??I try several ways but it doesn’t work…

ctrl + a = apply scale.

also typing S, and then X or y or z and a number and hitting enter is handy.

to set animation keys press I while pointing at the scale, or while in the 3d view and select the scale drop down.

to set the scale of a object in python it’s

own.scale(vector)

any item can have -

Ray---------------------------
mouse over-----------------python
mouse click----------------/

you can use a ray to set the target
Ray = cont.sensors[‘Ray’]

if ray.positive:
(tab)target=sens.hitObject
(tab)own.sendMessage(“scale up”, “”,target,own)

or even

(tab)target.scale.x = target.scale.x+.1

the bgui - can interface with a object and tell it to fire,

but the object that detects the item to scale needs to be in the scene it’s detecting I believe.

Before I get ahead of myself, do you want to scale a BGUI element or a game object?

You can modify the object’s worldScaling attribute to resize the object. You can either multiply it by a scalar constant, or set the length directly

here is a little example

left click = scale down, right click is scale up

Python


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner


    sens = cont.sensors['Mouse']
    sens2 = cont.sensors['MouseL']
    sens3 = cont.sensors['MouseR']
    if sens.positive and sens2.positive:
        own.worldScale=own.worldScale*.9
    if sens.positive and sens3.positive:
        own.worldScale=own.worldScale*1.1
main()

_____________LOGIC________________
Mouse---------\
Mouse1------python
Mouse2--------/

Mouse = mouse over

Mouse 1 = left click

Mouse 2 = right click

Attachments

MouseScale.blend (446 KB)