Game Development Reference
In-Depth Information
have the same position and angle as
mountpoint
it is attached to, specific-
ally a zero position and rotation offset relative to
mountpoint
. But remem-
ber, order is the key here!
public void
attachObjToMountPoint(GameObject go, int
index)
{
GameObject newGo =
(GameObject)Instantiate (go,
mountPoints[index].transform.position,
mountPoints[index].transform.rotation);
newGo.SetActive(true);
newGo.transform.parent =
mountPoints[index].transform;
newGo.transform.localPosition =
Vector3.zero;
newGo.transform.localEulerAngles =
Vector3.zero;//mount.transform.eulerAngles;
}
Congratulations! The monument system is now complete. We will interface with this
script in a later mission logic.
Creating the InventoryPlaceOnMonument class
This class loops over all the flags in the inventory and places them on the monument.
It loops over all the items and then attaches each one to each successive mount
point. This can be created by performing the following steps:
1. Create a new
InventoryPlaceOnMonument.cs
script. This will be at-
tached to a new Prefab for instancing later.
2. This script will cache a copy of the inventory manager by finding the
GameObject
named
Player
and then by getting and storing a reference to
the
inventoryMgr
component.