Can you set a value of a variable via animation?

Hello,

I’ve got a script with a public Vector 2.

I’m using an animation to change the value of the Vector 2. I can see this value change in the inspector.

However, if I do a print on the variable in Update(), the console doesn’t show any value.

Why is this the case?

Is it possible to use an animation to change the value within the script?

Figured it out. It was a case of needing to use LateUpdate().

It is, but there is timing to consider, and that is (probably) why you were able to make it work in LateUpdate():

Here is some timing diagram help:

https://docs.unity3d.com/Manual/ExecutionOrder.html

Aye, that was the diagram that helped me figure it out. I’ve never had to care too much about execution order, so it was a good bit of learning!

1 Like