Create Enemy3 based on already created Enemy1.
- 1 Previous tutorial
- 2 Preparation of Enemy3
- 3 Change the behavior of Enemy3
- 4 Next Step
Preparation of Enemy3
Duplicate Enemy1 Prefab
Duplicate ShootingGame / Prefabs / Enemy1.
If you duplicate it will automatically be named Enemy3, but if it is not, please leave it to Enemy3.
Place Enemy3 in the scene
To make it easier to work, place Enemy3 Prefab in the scene.
Please drag and drop the duplicated ShootingGame/Prefabs/Enemy3 to Hierarchy.
In order to distinguish it from other enemies, increase the scale.
Please change the Transform of Enemy 3 as follows.
|Scale||2, 2, 1|
Next, HP is also set to 100, making it hard to destroy.
Please change ParameterContainer of Enemy3 as follows.
The basic setting is completed so far.
Change the behavior of Enemy3
I will change Enemy3 to move and stop after 2 seconds.
Open in Arbor Editor
Open ArborFSM added to Enemy3 in the Arbor Editor window.
Please open by opening the Inspector’s Open Editor button.
Explanation of the Start state
In the Start state, SetVelocityRigidbody2D changes the velocity of Rigidbody2D of Enemy3 itself.
For details on SetVelocityRigidbody2D, refer to the Arbor reference “SetVelocityRigidbody2D”.
Also, we are making a transition with TimeTransition in order to start a shot after 1 second.
In this example, we want to stop moving 2 seconds later, so change Seconds to 2.
Create Stop State
Please create state with the name “Stop”.
As with Start, use SetVelocityRigidbody2D to stop the movement by setting the velocity to 0.
Please add “Physics2D / SetVelocityRigidbody2D” from addition of Behavior of Stop state.
It is set to stop by default, so you do not need to change anything in particular.
Since we want to start a shot after stopping, we will add GoToTransition and make it transition.
Please add “Transition / GoToTransition” from addition of Behavior of Stop state.
Since the setting of each state has been completed, we will reset the transition.
- Connect from the Time state Transition to the Stop state in the Start state
- Connect from GoToTransition in the Stop state to the Shot state
It should be OK if it looks like this.
Let’s check the operation by pressing “play button”.
After Enemy 3 moves from the top for 2 seconds, it stops and you can see how it fires enemy bullets.