Interactions - KSU-CS-Software-Engineering/VetMedSim GitHub Wiki

Architecture

This page is to describe the decision process on our sprite/interactive architecture. We’ve decided to make an InteractiveObject Interface to handle the basic actions for objects in the game such as desks, kennels, tables, and eventually other sprites such as animals or other players. The future plan is to create an interface for animals and usable equipment but as for now we will be keeping it simple for the BETA version. These interfaces will communicate with the InteractiveOject interface later on down the line.

As far as communication handlers for the sprite, we’ve found a good reference link with the calls we will need for the communication between multiple objects.

All interactable objects will have colliders attached to them so it would make it easier to extend how far/close you can be in order to interact with each other. In order to do this, we will use the OnTriggerEnter [1] method. We will acknowledge that the object has been triggered but will then have to check to see which of those objects are actually interactable by using the CompareTag [1] method.

In the Sprite class we will handle item highlighting and de-highlighting when moving around the map. Whenever the sprite triggers an interactable object we will make a call to OnCollisionEnter [1] and use a renderer to add a highlight to the nearby interactable objects. Likewise, we will use OnCollisionExit [1] to revert back to the original, non-highlighted object.

All interactive objects will have two colliders: trigger and solid. Triggers, as mentioned above, will help with interacting with certain objects. All objects, including non-interactables, will have a solid collider so the sprite will be unable to walk through things such as dogs, kennels, tables, walls, etc…

References: [1] https://docs.unity3d.com/ScriptReference/BoxCollider2D.html