3. About enemy bullet shooting


I will explain the enemy bullet launching in this tutorial.

Enemy3 ‘s ArborFSM does not fire enemy bullet directly, but indirectly controls Weapon of child object.

Previous tutorial

From Ememy3 to fire command

SendTrigger

Please look at the Shot state of Enemy3.

SendTrigger sends a trigger to Weapon, and the message is set to “ShotTrigger”.

On Weapon side, this “ShotTrigger” is triggered to control enemy bullet shooting.

Firing process by Weapon

TriggerTransition

Please select the Weapon object in the child of Enemy3 and look at the Arbor Editor.

The “ShotTrigger” message comes in when the TriggerTransition used for the Start state comes.

In the Stop resident state, it waits for the “StopTrigger” message, and when a message comes, it instantaneously transits to the Start state.

In this way, by using SendTrigger and TriggerTransition, it becomes possible to create a mechanism to link objects.

See “SendTrigger” and “TriggerTransition” for more information.

LookAt2DObjectWithTag

LookAt2DObjectWithTag used in the Rotation resident state is the StateBehaviour this time created for 2D Shooting Game.

It is a script that turns the Transform specified in the Transform field to the object direction specified by Tag.

This time we are realizing our aim by bringing Weapon to the player direction.

About Shot state

In the Shot state, an EnemyBullet prefab is generated from ShotPosition1 and ShotPosition2 using InstantiateGameObject.

Then wait for 0.5 seconds with TimeTransition and continue to generate EnemyBullet repeatedly.

About EnemyBullet

In the EnemyBullet object, I move it using SetVelocityRigidbody2D.

Next Step

4. Create Weapon