Notifications
Clear all

[Closed] float script problem

hi,
I assigned a float script to X position, wrote some expression and at the end I need to have something like this Xposition = Xposition + something. I tried to create a variable and assign it to X pos but there is an error due to circular dependency. Is there any way to do what I want?

thx!

4 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Xposition = Xposition + something
this doesn’t make any sense for me. It might be position_x = <expression> + <something>. You don’t need to (and you can’t) use the controller itself in its own expression.

What if you do Xposition += something instead?

 lo1

I think it can be done only if you put the script controller on a different object than the one you are affecting.

But either way I think it is a bad idea to do any kind of incrementation on a script controller, or in other words, to have a value affected by the value of the previous calculation. This is because it is not always the previous frame which is the previous calculation – for example if you are scrubbing the time slider, and you will get very unexpected results.

 PEN

What you need to do is create a CA def with a single float parameter that is non-animatable, we will call it lastVal, store the calculated value here and the last line of the script controller is this.lastVal+=xPosition.

The only issue with doing something like this is I a user skips a frame by clicking further ahead in the animation the solution will not be correct. What you need to do is bake the solution. You will also have to do this for network renders as well.