Interactables - AnduoGames/ThirdCrisisModding GitHub Wiki

Interactables are colliders that Jenna can Interact with when standing next to them and presses the Use button. To create an interactable, we have to create a GameObject to host it, a Collider to define the size and the Interactable itself.

var interactableGameObject = new GameObject();
// Set the position of the Interaction
interactableGameObject.transform.position = new Vector3(10f, 3f);

var boxCollider = interactableGameObject.AddComponent<BoxCollider>();
// Set the size to 1 by 1 meter.
boxCollider.size = new Vector3(1f, 1f);

var interactable = interactableGameObject.AddComponent<Interactable>();
// This only sets the Icon
interactable.TypeOfInteraction = InteractionType.Talk;
interactable.OnInteracted.AddListener(x =>
{
    Debug.Log("I was interacted with!");
});