Animating our three-dimensional enemies
Here's a really easy, quick animation with the script for your enemies. Currently, the enemies just move up and down in a wave pattern. However, the units themselves remain static.
Let's give our enemies a bit of extra life with some code:
- In the Project window, go to
Assets/Prefab/Enemies
. - Double-click on the
enemy_wave
prefab and select theenemy_wave_ring
in the Hierarchy window. - In the Inspector window, click on the Add Component button.
- Click on New Script at the bottom of the dropdown.
- Name the new C# script
BasicEnemyRotate
. - Then, enter this code:
using UnityEngine; public class BasicEnemyRotate : MonoBehaviour { [SerializeField] float speed = 0; void Update () { transform.Rotate(Vector3.left*Time.deltaTime*speed); } }
This is a tiny script that animates the part of our enemy. There are two things to look closely at:
- The variable is a private...