A third and forth block project, an educational game made for Wildlands Zoo Emmen to attract visitors and enhance their zoo experience.
Edutainment
Touch Screen PC
Unity
As an only programmer I was responsible for 100% of the game's code. I used C# to code main game systems: Movement Controls, Scanning of Environment system, Feeding system.
// Check for raycast to animal part and display correct info
private void CheckGaze()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
// Check ray collider tag and display correct text based on tag
string part = hit.collider.tag;
string[] partList = { "Head", "Body", "Ears", "Back Legs", "Front Legs", "Horns", "Mouth", "Tree", "Grass", "Waterhole", "Bird", "Feces"};
if (lastPartHit != part) {
// Check if list contains the part
if (partList.Contains(part))
{
lastPartHit = part;
UpdateStats(part);
OpenInformationPanel(Storage.animalInfo[animalID][part][0], Storage.animalInfo[animalID][part][1], Storage.animalInfo[animalID][part][2]);
}
else
{
lastPartHit = null;
CloseInformationPanel();
}
}
}
else
{
lastPartHit = null;
CloseInformationPanel();
}
}
// Update stats
private void UpdateStats(string part)
{
// Update list with new part if it is new part
if (!Storage.animalPartsScanned[animalID].Contains(part))
{
Storage.animalPartsScanned[animalID].Add(part);
for (int i=0; i< bodyParts.Count; i++)
{
if (bodyParts[i].name == part)
{
bodyParts[i].SetActive(true);
}
}
}
// Check if sticker is collected
if (!isStickerObtained)
{
// Check all bodyparts if they are collected
List<string> allBodyParts = new List<string> { "Head", "Body", "Ears", "Back Legs", "Front Legs", "Horns", "Mouth"};
for (int i=0; i < allBodyParts.Count; i++)
{
if (Storage.animalPartsScanned[animalID].Contains(allBodyParts[i]))
{
// If all collected disable individual parts and display full sticker
if (allBodyParts.Count-1 == i)
{
rhinoStickerSilouete.SetActive(false);
rhinoSticker.SetActive(true);
for (int k=0; k < bodyParts.Count; k++)
{
if (allBodyParts.Contains(bodyParts[k].name))
{
bodyParts[k].SetActive(false);
}
}
isStickerObtained = true;
}
}
else
{
break;
}
}
}
}
The Scanning system sends out a ray and captures the gameobject tag, if the tag is in the list, it loads the information for that body or habitat part.
The code also checks for UI sticker elements and activates them for a corresponding part.
The Movement controls are designed to control 2 control points, the arm of the 360 camera going around the animal and a camera span with deadzones.
The Joystick is custom designed to just control the camera span to look around the habitat.
void Update()
{
// Drive arm control
if (armUp)
{
var RotCheckVal = rotationX + cameraArmMovementSpeed;
if (-10 <= RotCheckVal && RotCheckVal <= 10){
rotationX += cameraArmMovementSpeed;
}
}
if (armDown)
{
var RotCheckVal = rotationX - cameraArmMovementSpeed;
if (-10 <= RotCheckVal && RotCheckVal <= 10)
{
rotationX += -cameraArmMovementSpeed;
}
}
if (armLeft)
{
rotationY += cameraArmMovementSpeed;
}
if (armRight)
{
rotationY += -cameraArmMovementSpeed;
}
focalPoint.rotation = Quaternion.Euler(rotationX, rotationY, 0);
// Camera move control
if (Joystick.horizontal != 0 || Joystick.vertical != 0)
{
var RotTempValX = cameraYAddition + Joystick.horizontal * cameraMoveSpeed;
var RotTempValY = cameraXAddition + Joystick.vertical * -cameraMoveSpeed;
if (-cameraDeadZone <= RotTempValX && RotTempValX <= cameraDeadZone) { cameraYAddition += Joystick.horizontal * cameraMoveSpeed; }
if (-cameraDeadZone <= RotTempValY && RotTempValY <= cameraDeadZone) { cameraXAddition += Joystick.vertical * -cameraMoveSpeed; }
cam.rotation = Quaternion.Euler(rotationX + cameraXAddition, rotationY + cameraYAddition, 0);
}
// Zoom in and out control
if (zoomIn)
{
var TempZoomVal = fovVal -zoomSens;
if (20 <= TempZoomVal) { fovVal += -zoomSens; }
}
if (zoomOut)
{
var TempZoomVal = fovVal + zoomSens;
if (60 >= TempZoomVal) { fovVal += zoomSens; }
}
c.fieldOfView = fovVal;
}
// Arm Drive boolean changers for buttons
public void ArmDriveUp(int value)
{
if (value == 1) { armUp = true; }
else { armUp = false; }
}
public void ArmDriveDown(int value)
{
if (value == 1) { armDown = true; }
else { armDown = false; }
}
public void ArmDriveLeft(int value)
{
if (value == 1) { armLeft = true; }
else { armLeft = false; }
}
public void ArmDriveRight(int value)
{
if (value == 1) { armRight = true; }
else { armRight = false; }
}
Modeled and textured the Rhino.