Menu
CoddyTech

Recap: Interact Key

Part of the Game Architecture in Unity section of Coddy's Unity journey. Lesson 10 of 64.

challenge icon

Challenge

Easy

Give the player an interact key; Interactor is ready.

  1. Declare public interface IInteractable with void Interact();, and make Door, Chest and Lever implement it.
  2. Door: turns 90 degrees around y, logging Door opened, then back, Door closed.
  3. Chest: Found 5 coins, then The chest is empty.
  4. Lever: switches bridge on or off and logs Lever pulled.

Press Play and use everything. Then Check.

Try it yourself

using UnityEngine;

public class Door : MonoBehaviour
{
}

All lessons in Game Architecture in Unity

Practice on your own: Unity playground