This is a long class, so it is important to carefully follow these steps:
- First, create the rival's class, as follows:
using UnityEngine; using System.Collections; public class AirHockeyRival : MonoBehaviour { // next steps }
- Next, declare the public variables for setting and tuning it up, as shown in the following code:
public GameObject puck; public GameObject paddle; public string goalWallTag = "GoalWall"; public string sideWallTag = "SideWall"; [Range(1, 10)] public int maxHits;
- Declare the private variables, as follows:
float puckWidth; Renderer puckMesh; Rigidbody puckBody; AgentBehaviour agent; Seek seek; Leave leave; AHRState state; bool hasAttacked;
- Implement the Awake member function for setting up private ...