I’m using scripting to modify an object (iceNull) such that its scaleX and opacity change based on distance from the camera. Distance is working properly. Opacity is changing as expected. However, the object’s scale does not change. I’ve debugged down to the issue that object.transform.scaleX does not change when it is assigned to be a scalar signal but works when it is assigned a normal (non-signal) number. However, I need it to be a signal because I want it to scale with camera distance. To illustrate the issue, I’ve simplified the code to remove the distance calculation and just show the code compare assigning it to a constant scalar signal vs. a constant normal number.
So this works ((i.e., the iceNullScale correctly changes to 40 when monitored with Diagnostics.watch)
let scale = 40;
iceNull.transform.scaleX = scale;
let iceNullScale = iceNull.transform.scaleX;
And this does not work (i.e., the iceNullScale stays = 1 when monitored with Diagnostics.watch):
let scale = Reactive.val(40);
iceNull.transform.scaleX = scale;
let iceNullScale = iceNull.transform.scaleX;
I realise the problem is because I was using the position from a null object to calculate the distance-from-camera-signal that I was using for the scale value and then assigning this back to the same null object’s scale value. This gets fixed if I instead create a nested null object that I apply the scale to. I don’t fully understand why it’s a problem to use the worldTransform.position-signal from an object and then use a calculation on that signal to determine the same object’s transform.scaleX (a different property under local transform). I have that asked as a question in a simpler example in my other post here: