[Unity/Playmaker]Make Warriors VR: How to make enemy character’s movement and collision detection

In this article, I am going to introduce the movement of the enemy character and the way to make a collision detection using Unity’s Playmaker.
Enemy characters are made to come at the player whereever the player is.
And it’s set to disappear when it hits the player’s sword.
The previous article describes the settings so far, take a look.

Previous post

 

完成シーン

completed scene

 

Checking the sample assets in STYLY Studio

Launch the STYLY Studio to check sample assets in the STYLY Studio
Launch the WebEditor

If you have registered with STYLY, you can check the sample assets created in this TIPS with STYLY Studio. If you do not have an account, please register a new account first and click this button again.

Click here to register your account
Click here

 

Sample

You can experience the sample space from STYLY GALLERY.

Gallery page You can download the Unity project described in the article here.

Sample project

Assets in use

Use the Playmaker and Move Motion Free Pack.

 

Playmakerを使用します

Use Playmaker

 

Move Motion Free Pack

Move Motion Free Pack

Setting up a character

Adding a component

First, it gets a hit judgment.
For more information on how to do this, see the article below.

Add a Rigidbody and a Capsule Collider to get a hit signal when a character is attacked.

Select a prefabricated “Nakagawa” to add components.
Uncheck “Is Kinematic” for Rigidbody.
Use Gravity is also unchecked.
Uncheck the Is Trigger on Capsule Collider.
Adjust the Center, Radius and Height values to fit the body shape.

RigidbodyとCapsule Colliderの追加

Adding Rigidbody and Capsule Collider

Setting the State

Select “Nakagawa” in the Prefabs folder and add the FSM here.

Right click the Playmaker Editor and create a new state from Add State.
For information on how to attain camera information (player information), see the article below.

Get the main camera to get the player on VR. Add a Find Game Object.
Set the Object Name to “[VRTK]_VIVE”.

[VRTK]_VIVE

Select a Store and store it in the “MainCamera” variable.

 

Stored in “MainCamra” variable

Add a Look At so that the character faces the player.
Specify MainCamera for the Target Object. Check the Keep Vertical box.

 

Look At settings

Now the character is facing the player (MainCamera).
Next, we try getting closer to the player.
We’ll be using Move Towards here.
Specify MainCamera for the Target Object.
Check the Ignore Vertical box.
Set the value of Max Speed to 2 in this case.
Finish Distance is left at 1.
If you set it to 0, it will move to the target object’s position, but if you set it to 1, it will stop a little before the target object.

The higher the number, the farther it is going to stop.

 

Move Towardsの追加

Add Move Towards

Now you have a character that goes to the player.

Let’s add a COLLISION ENTER event to State1 in order to get a win decision.

With State 1 selected, right-click and select Add Transition > Ststem Events > COLLISION ENTER.

 

Add COLLISION ENTER

We want the object to be deleted when it collides, so we’ll add a state to do so.

Add Destroy Self to remove itself when it collides.

Destroy Selfの追加

Adding Destroy Self

This completes the configuration.

All that’s left is to upload the prefabricated “STYLYmusou” made in Vol.1 to STYLY and place it in the scene.

How to upload assets from Unity to STYLY

In this article, I have introduced how to use Playmaker to determine the direction of character movement and collision detection.

In the two-part series with Vol.1, I have introduced the way to make a warrior-like game with STYLY.

I think VR and Warriors-like games are very compatible, so I’d love to create more of them.

The game would be more powerful if you added a beatdown motion when attacked or added with sounds and effects.
It’s great that you can turn your scan data into a VR game and publish it easily.

The 3D model used in the article can be found in the sample project.
The use of 3D models is available only in STYLY.
As long as you can use it within STYLY, there are no restrictions on modification or alteration.