I need a full set of scripts to create a psychological horror game in Unity called Mr. John. The core character, Mr. John, is an unsettling, humanoid figure who interacts with the player by following them or guiding them to specific points in the environment to complete puzzles. You, the AI, should create the necessary scripts from scratch, including naming conventions and logic. Please ensure that all the scripts work together to create a seamless gameplay experience.

Here are the core elements and mechanics of the game, with clear instructions for how they should function. You can decide how best to implement the details, but ensure they adhere to the core ideas:

Core Mechanic: Mr. John’s Behavior
Following the Player:

Mr. John should be able to follow the player character at a set distance.
The player’s camera (first-person or third-person) should be the reference point for Mr. John’s movement, and Mr. John should smoothly navigate behind the player using Unity’s NavMesh system.
Mr. John should maintain a certain distance when following the player but should always be within visual range to maintain the eerie, unsettling presence.
Allow for toggling this behavior on and off based on events in the game, such as completing puzzles or when the player interacts with the environment.
Guiding the Player to a Destination:

Mr. John can also move to a specific point in the game world (set by a destination or objective) when required.
The script should include a method to switch between "follow player" mode and "move to destination" mode.
The destination point can either be set via UnityEvents or a Transform input.
Visibility and Animation:

Mr. John should have the ability to toggle his visibility, giving the impression that he appears and disappears in specific moments. This toggle could be based on in-game triggers or player actions.
Mr. John should also have an eerie look and feel. His animations should reflect this by using an Animator component, with specific animation states (e.g., idle, moving, etc.).
Ensure visibility changes and animations are synchronized, such that when Mr. John appears, his body gradually fades in, and his movements are slightly unnatural but not overtly monstrous.
Looking at the Player or a Target:

Mr. John should always face the player (or the destination) when either following or moving to a point.
The rotation should be smooth to avoid breaking immersion and use Quaternion functions to ensure smooth transitions between angles.
When following the player, Mr. John’s body should rotate to face them while keeping his distance behind them.
Puzzle Interaction
Puzzles and Task Completion:

In the game world, the player interacts with various puzzles and tasks that Mr. John will guide them toward.
Each puzzle should have a script attached to it that tracks whether the puzzle has been completed.
Once completed, the puzzle sends a signal to Mr. John’s controller to trigger a new behavior (e.g., move to the next destination, make Mr. John disappear, or unlock a door).
Prefab Setup:

Create a script for each puzzle or object that allows it to track its completion state and invoke methods when the puzzle is finished. This should be flexible so that different puzzles can be created as prefabs with this script attached.
Ensure the puzzle script can interface with Mr. John’s controller (likely via UnityEvents or delegates) to trigger behavior changes when the puzzle is solved.
Tools and Structure
NavMesh Movement:

Use Unity’s NavMesh system to handle Mr. John’s movement when following the player or moving to a destination. Make sure the pathfinding is smooth and takes into account obstacles and environmental factors.
Mr. John should be able to start and stop moving fluidly based on conditions (e.g., freeze when idle, unfreeze when moving).
Player Reference:

Mr. John’s behavior should reference the player’s position, either through their camera or another object attached to the player. If the player object is not assigned, default to Camera.main.
Ensure Mr. John’s movement respects this reference and always acts relative to the player’s position.
Public Methods and UnityEvent Support
Public Methods for Flexibility:

Create public methods for all core actions that can be called via UnityEvents or other scripts, including:
Toggling between following the player and moving to a destination.
Setting a new destination point for Mr. John to move toward.
Toggling visibility on and off.
Freezing and unfreezing Mr. John’s movement.
Detecting and responding to puzzle completion events.
Smooth Integration with Unity:

The code should be modular and easy to integrate into Unity. Ensure that key variables (like follow distance, speed, visibility states, etc.) are exposed in the Unity Inspector so they can be adjusted easily.
Any input from UnityEvents should be designed in a way that allows non-programmers to trigger Mr. John’s behaviors during gameplay without modifying the code.
Error Handling and Robustness
Fallbacks and Error Handling:
If player objects or destination points are not assigned, the code should handle these cases gracefully by falling back on sensible defaults (e.g., using Camera.main as a reference for Mr. John’s movement).
Make sure all movement and behavior transitions (such as switching between follow mode and destination mode) are smooth and don’t result in jittery or unnatural movement.
You, the AI, can decide on how to name all variables, methods, and classes in a way that makes sense based on the functionality. Please ensure that the scripts are modular, reusable, and integrate smoothly into Unity. I will handle object configuration in Unity, so the code should focus on creating the logic and ensuring all parts of the system work cohesively together. Make sure all scripts are complete and can interact with each other correctly."