Basic


For this time, we will make an easy mechanism to switch ON / OFF at 1 second intervals.

Operating environment

This tutorial is created in the following environment.

  • Unity 5.3.0f4
  • Arbor 2.2.0

Depending on the version, please understand that there are parts different from the explanation.

Create tutorial project

First of all, please create a project for the tutorial.

Project Name ArborTutorial01
Mode 3D
Assets to import Arbor

For information on creating projects and importing Arbor, please refer to “Get Started : Preparation for using Arbor”.

Create ArborFSM object

Create an ArborFSM object to make the state machine available.

From the Create button of the Hierarchy window, select “Arbor> ArborFSM” to create a GameObject with ArborFSM component.

GIF

This ArborFSM is a component for operating the state machine.

Displaying the Arbor Editor window

To edit ArborFSM, do it in the Arbor Editor window instead of the Inspector window.

Please click on the Open Editor button in Inspector of ArborFSM to display it.

When clicked, the Arbor Editor window with ArborFSM selected is displayed.

Since you will often use the Arbor Editor window, it’s a good idea to dock it in an easy-to-use position.

Create OFF state

Since we only handle two states ON / OFF this time, we will first create two states.

First, right click on a place where there is nothing on the graph and select “Create State”.

Since the name of the state is named “New State”, we recommend changing to a meaningful name.

In this example, set the state name to “OFF”.

GIF

Create ON state

Continue to create an ON state.

Just like “Create OFF State”, right click on the part of the graph where there is nothing and select “Create State”.

Let the state name be “ON”.

GIF

About “Start state”

When you create a state from nothing, the state you created the first time becomes the “Start state”.

Start state” is the state that becomes effective at the beginning of execution.

In this case, the OFF state is set to “Start state”.

To change “Start state”, click the setting icon of “Normal state” and select “Set Start State”.

GIF

In this time, the OFF state is “Start state” so it will not be a problem so I will put it back.

GIF

Switch state over time

Next, we will set the behavior of the state.

To add behaviors, perform “Add Behaviour” from the setting icon.

Click the OFF state setting icon and select “Add Behaviour”.

GIF

Since we want to transition over time, we add “Transition> TimeTransition” here.

GIF

TimeTransition transitions to the state specified in “Next State” after the number of seconds specified in “Seconds” elapses.

For this time we will set the transition time to 1 second.

Set Seconds of TimeTransition to 1.

GIF

Then, specify “Next State” to transition to the ON state.

Please drag and drop the “Next State” button to the ON state.

GIF

Now it will transition to the ON state after 1 second has elapsed.

For more information about TimeTransition, see TimeTransition reference.

In addition, Arbor has built-in behaviour of 100 or more beforehand, so please refer to Arbor reference for what behavior is there.

Setting the ON state

In the ON state as well, we will set it to transition over time.

Since there is a TimeTransition already set to the OFF state, copy and paste is performed.

First, click the TimeTransition setting icon in the OFF state and select “Copy”.

GIF

Next, click on the setting icon in the ON state and select “Paste Behaviour”.

GIF

Including each parameter of TimeTransition was copied and pasted.

I want to transition from the Time state TimeTransition to the OFF state, so reconnect the “Next State” to the OFF state.

GIF

This made it possible to switch ON / OFF at 1 second intervals.

Confirm the operation so far

Let’s try once and check the operation.

Press “Play button” to execute.

If you look at the Arbor Editor window during execution, you can see that “Current State” switches at 1 second intervals.

GIF

However, since you can not see any change in Game View as it is, leave the Cube behind and let it look visually.

Create a Cube object

From the Create button of Hierarchy, select “3D Object> Cube”.

GIF

A Cube object was created in the scene.

Deactivate in OFF state

In the OFF state, you want to inactivate the Cube object, so use ActivateGameObject to set it.

Click the OFF state setting icon, select “Add Behaviour”, select “GameObject> ActivateGameObject” and add it.

GIF

When ActivateGameObject is added, make setting.

Leave “Target” to Cube, “Begin Active” and “End Active” unchecked.

GIF

This makes the Cube object inactive in the OFF state.

For more information about ActivateGameObject, see ActivateGameObject reference.

Activate in ON state

Since we want to activate the Cube object when entering the ON state, we set it by using ActivateGameObject like the OFF state.

Again, let’s copy and paste from the ActivateGameObject in the OFF state.

Select “Copy” from the setting icon of the ActivateGameObject in the OFF state, and select “Paste Behaviour” from the setting icon of the ON state.

GIF

Copy and paste was done with the Cube object set to “Target”.

Next, in the ON state, you want to activate it, so check “Begin Active” and “End Active”.

GIF

This will activate the Cube object when entering the ON state.

Operation check

Let’s check at the end whether the Cube object will be switched or not.

Press “Play button” to execute.

GIF

Now you can see that the Cube object’s activity switches at 1 second intervals.

If you also check the Arbor Editor window, you can see that the Cube object is switched normally in conjunction with the state change.

GIF

Next step

This completes the “Basic”.

“Basics” complete tweets

Next time is “Coding”.

I will explain how to create Arbor scripts.

コーディング編