Assigned Variable Scope

Ex-Crow 3 years ago updated 3 years ago 3

Would it be possible for assigned variables to be used in indirectly related flows?  Generally, the recommendation is to split input from physics that impact the character controller so that no input is lost between physics steps refreshes. In that case, I'd have the input in Update but the change in velocity in Fixed Update so that character moves at the same speed independent of framerate.

While I can do that with Bolt variables it would be great if I could achieve that in a cleaner way with local assigned variables. Unfortunately, it's currently out of scope:

Graph: https://imgur.com/WEvc3b2

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Bolt 2

Same graph with Bolt variables that works as intended. Considerably longer, harder to set up and with a messier, harder to read C# code that's generated. https://imgur.com/O13hqUL


Hi TowerCrow,

No, assigned variables are basically exactly like Locals in traditional code. This is what makes them essentially free (stored on the stack) and very fast. They will not become accessible across different scopes.

However, class variables will allow you to do exactly that!

Thank you for your answer. I guess I'm confusing local variables with class variables.