Video Tutorial: Ani...
Clear all

[Sticky] Video Tutorial: Animating with Playmaker  


Joined: 2 years ago
Posts: 143
05/09/2018 2:02 pm  

Get runtime models MOVING with Playmaker!

Archimatix: Animating with Playmaker

1. intro

I’ll use Playmaker to animate an Archimatix runtime model.
I’m targetting this video for beginners of both Playmaker and Archimatix, so I’ll keep it simple and step-by-step.

Playmaker will generate random float variables, and update the model’s exposed runtime parameters.

In actual use, these parameters would be tied to a game mechanic or player stats or some user interface. I don’t care what the numbers are, I just want them to change so I’ll use random.


2. Archimatix Parameters

In Archimatix, I open the Parameter settings I want to animate, and check EXPOSE.
I’ll do this for each parameter that will be animated.

The Runtime Parameters appear in the Inspector in the order they were created. 
I can rename each one with an alias.

Create the runtime controller script, give it a name without spaces or punctuation, and save it in your project.

A RuntimeController gameobject is created inside the Archimatix model. When I need to GET and SET the parameters on the model, Playmaker will target this GameObject, specifically the controller script.


3. Playmaker

I’ll create a new FSM, and this could be on any gameobject, it could be on a brand new object or a central “scene manager”, but for this tutorial I’ll build the FSM on the root of the Archimatix model. 

With the gameobject selected, right-click in the Playmaker Editor.

Playmaker opens with a blank Start State, and I’ll drag the runtimeControler gameobject into the empty State panel. This opens a popup where Playmaker offers a list of generic things it can do, but I am only interested in this script component, which is the name of that runtimeController I made.

Under my script I have 3 options: GET PROPERTY, SET PROPERTY, and under scriptControl I have a 3rd option CALL METHOD – This will be important later, but at first I just want Playmaker to GET the Archimatix parameter… and store it as a float variable which I’ll name “myHeight”.

I add a RANDOM FLOAT action, set the target range, and create another PlayMaker variable to hold the random value. I’ll call this new variable “toHeight”.

To finish the state, I right-click on the node in the graph and select TRANSITION -> FINISH



4. Ease Float

CMD-Click on the transition and drag to create another state node.

In the new State, I add the EASE FLOAT action, and set the From Value to myHeight, and set the To Value as toHeight. This works like any other tweener in Playmaker: set the Ease In/Out, and the Time. Create the FINISH event, for when the EASE FLOAT Action is done. 


5. Set Property

While EASE FLOAT is running, our state engine stays in this Node, and it will rerun the actions that have EVERY FRAME checked. If you leave EVERY FRAME unchecked the actions will only fire once. 

So while EASE FLOAT is running, I’m going to SET the parameter on the model, every frame.

This time I’ll add the action a little differently, just to show another method. Select the RuntimeController in the heirarchy and lock the inspector window. Switch back to the GameObject with Playmaker, and drag the component into the State panel.

I select the SET  PROPERTY action from the popup, choose my exposed parameter, and set the variable to myHeight.
I want it to update EVERY FRAME.


6. Call Method

The last step is to add the CALL METHOD, and there are only 2 options (the 3rd option is generic) BuildGameObjects and BuildAllGameObjects…, I’m not sure what the difference is but I’ll pick the one that sounds like it is doing LESS work.

And I want to send the call method to rebuild EVERY FRAME.


7. Loop and Play

In Playmaker I’ll finish the FSM by looping back to the start state, and hitting PLAY.


8. Animating Multiple Parameters

If I want to animate the other parameters, I can daisychain the states so they animate one after another, or I can merge them all under one EASE FLOAT timer and when the CALL METHOD rebuilds, it will generate all parameters at their current float settings. Different parameters could develop at different speeds giving each an organic or mechanical feeling.

Animating deformers is also possible.


9. Tips and Tricks

Now if you are thinking that Archimatix models can become bloated and slow, and it will take too long to rebuild, and a complex model would never animate this cleanly, you are right.

But I’ve learned some tricks to this:

2D Shapes, the Sections and Plans at the foundation of the model are always slow. They force the entire model to rebuild from scratch, and because they change the foundation shape, every node that relates to them needs to update.

Animating something inside a grouper is slow, I’m pretty sure it triggers everything within that Grouper to update — you can experiment and see if that is happening with your model, and maybe it can be avoided by rethinking the graph arrangement.

Extrude and Lathe are relatively fast, especially if there are no new vertices being created. If the mesh doesn’t need to be rebuilt from 2D shapes it can be moved and resized in real-time.

Floors and Repeaters are very fast to animate even if the building is very large, That’s because Archimatix moves the heavy work to the GPU with Unity instances. Instances can be moved around very quickly, and that includes offsetting and rotating the floors which looks impressive.

3D transforms are fast, it’s just Unity moving geometry, so look for ways to move vertices that are already in the scene.


Also, remember that both Archimatix and Playmaker run faster in builds than in the Unity Editor.
And for huge, bloated Archimatix models that haven’t got a chance of animating in real-time, there’s always offline rendering.

This topic was modified 2 years ago by wetcircuit

Topic Tags