Sonntag, 12. April 2020

Unity - modify Parameters of animator transactions via scripting

There are animations.
Each animation got an animator.
Drop as many other animation animator to the current animator optionaly.
Connect each animator element through new transactions. (right click on the element).
Add a parameter to the transaction of type float, bool etc.
Add a condition to the transaction to be true or false.
The condition is the result of a comparison of such Parameters.

How to feed the Parameters from code in order to let the animator decide which condition is true and finally to change the desired animation?

Make a public class member of type animator:

public Animator animator;

Feed this public Animator variable in the UI of  Unity by draging and dropping the animator of the same gameObject over there. Now is the specific gameObject animator linked to the gameObject public script variable. 

Set the Parameter of the Animator:

animator.SetFloat("MyTransactionFloatParameter", 0.01f); // for instance

0 Kommentare:

Kommentar veröffentlichen

Abonnieren Kommentare zum Post [Atom]

<< Startseite