Getting ready

We will need to create three base classes that are the data types to be used by the high-level classes and algorithms. The Location class is very similar to the Steering class and is used to define a target position and rotation given the formation's anchor point and rotation. The SlogAssignment class is a data type to match a list's indices and agents. Finally, the Character class is a component to hold the target Location class.

The following is the code for the Location class:

using UnityEngine; 
using System.Collections; 
 
public class Location 
{ 
    public Vector3 position; 
    public Quaternion rotation; 
 
    public Location () 
    { 
        position = Vector3.zero; 
        rotation = Quaternion.identity; 
    } 
 
    public Location(Vector3 position, Quaternion rotation) 
    { 
        this.position = position; 
        this.rotation = rotation; 
    } 
}

The following is the code for the SlotAssignment class:

using UnityEngine; 
using System.Collections; 
 
public class SlotAssignment 
{ 
    public int slotIndex; 
    public GameObject character; 
 
    public SlotAssignment() 
    { 
        slotIndex = -1; 
        character = null; 
    } 
} 

The following is the code for the Character class:

using UnityEngine; 
using System.Collections; 
 
public class Character : MonoBehaviour 
{ 
    public Location location; 
 
    public void SetTarget (Location location) 
    { 
        this.location = location; 
    } 
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.141.23