[SOLVED] How to set size of spatial

Hey guys,

how do I set the size of a spatial? Seems kinda basic but all I found is Spatial.scale() that

Scales the spatial by the given value

There should be a way to set a spatial to an abitrary new size without caring about or knowing its current size, right?

What am I missing?


Did you look at the javadoc? You want to “set” the “scale”, right?

Yup, that quote is from scale’s javadoc.

I want to make my spatial for instance to become 2 units wide, not to increase its size by 2 units.

Let’s say I tried something like this to make my Object “pulse”:

public void simpleUpdate(float tpf) {
    float size = FastMath.sin(tpf);

Since scale() changes the spatial size depending on the current value, this snippet will of course not work as intended.

Use Spatial.setLocalScale(float) :slight_smile:

Some methods work (as you discovered) on the current state (scale/rotation/location) of the spatial. Other methods work on the initial state of the spatial.

Take a look at the tutorials, one of the first ones explains this.

Thanks that worked. :slight_smile:

For the sake of completeness:

public void simpleUpdate(float tpf) {

    float size = 1f + FastMath.sin(
         java.lang.System.nanoTime() / FastMath.pow(10, 9)