メインコンテンツまでスキップ

「Unity」タグの記事が12件件あります

Technical deep dives into Unity Engine.

全てのタグを見る

Building a Sanity System: Coding Eternal Darkness

· 約2分
Thang Le
Senior Lead Engineer

Sanity System

Attacking the Player, Not the Character

In 2002, Eternal Darkness: Sanity's Requiem introduced "Sanity Effects" that didn't just affect the character—they targeted the player. From "deleting" save files to muting the TV, these meta-scares are legendary. Building a modern equivalent in C# for Unity requires a robust, modular architecture that can handle a wide variety of "hallucinations."

The Sanity Controller

The core of the system is a centralized SanityManager. This class tracks a normalized value from 0 to 1 and fires events as the player crosses certain thresholds.

public class SanityManager : MonoBehaviour {
public float Sanity { get; private set; }
public UnityEvent<SanityLevel> OnSanityTierChanged;

public void ModifySanity(float amount) {
Sanity = Mathf.Clamp01(Sanity + amount);
// Tier checking logic...
}
}

Modular Hallucinations

We don't want the SanityManager to know about every possible effect. Instead, we use a Command Pattern or a ScriptableObject-based Effect System.

  1. Visual Hallucinations: These are driven by Post-Processing. As sanity drops, we increase the intensity of a "Lens Distortion" or "Color Shift."
  2. Auditory Hallucinations: Using our Binaural audio system, we play "phantom sounds" (whispers, footsteps) behind the player that have no physical source in the world.
  3. Mechanical Hallucinations: These are the "meta" scares. In Unity, this might involve subtly changing the player's movement speed, reversing their input for a split second, or showing a "fake" loading screen.

The Risk of Frustration

The golden rule of Sanity Systems is: Never break the game. A sanity effect that causes a real crash or a real loss of progress is a bug, not a feature. The goal is to make the player think the game is breaking.

For Lil Sis, we've refined this by ensuring that all sanity effects are strictly visual or auditory. We want to gaslight the player's senses, not their patience. By building a system where "hallucinations" are just another layer of the rendering and audio stack, we can create a deep, unsettling experience that feels like the world itself is coming apart at the seams.

F.E.A.R. AI: Still Unbeatable in 2026?

· 約2分
Thang Le
Senior Lead Engineer

FEAR AI

The Gold Standard of Tactical Terror

Released in 2005, F.E.A.R. (First Encounter Assault Recon) is still frequently cited as having the best AI in any first-person shooter. Even in 2026, many modern titles struggle to replicate the feeling of fighting a coordinated, intelligent team of enemies. The secret wasn't just complex logic; it was a revolutionary architecture called GOAP (Goal Oriented Action Planning).

What is GOAP?

Unlike traditional "Finite State Machines" (where an enemy is either in an "Idle," "Search," or "Attack" state), GOAP allows the AI to decide how to achieve a goal based on the current world state.

If an AI's goal is to KillPlayer, it looks at its available actions:

  • ShootPlayer (requires weapon, line of sight)
  • AdvanceToCover (requires cover nearby)
  • FlushPlayerWithGrenade (requires grenade, player in cover)

The AI "plans" a sequence of actions that leads to the goal. This leads to Emergent Behavior. If you suppress an enemy, they don't just "go into cover state." They plan a route to cover while another AI plans a suppressive fire action to cover them.

The Illusion of Communication

F.E.A.R.'s AI feels intelligent because it "talks." The enemies call out their actions: "Flanking!", "I'm suppressed!", "Grenade out!" From a technical standpoint, this is just the AI broadcasting its current "Action" to the audio system. However, for the player, it creates the illusion of a highly coordinated tactical unit.

Implementation in Modern Engines

Building a GOAP system in Unity or Unreal is more accessible than ever.

  1. The Planner: A simple A* search algorithm that traverses the "Action Space" to find the cheapest path to a goal.
  2. The World State: A set of boolean flags (e.g., HasWeapon, PlayerInSight, NearCover) that the AI uses to evaluate its plan.
  3. Blackboards: Shared data structures that allow team members to share information about the player's last known position.

The legacy of F.E.A.R. is that great AI isn't about being "hard" to beat; it's about being believable. By giving enemies goals and the tools to achieve them dynamically, you create a game where every encounter feels unique and every enemy feels like a thinking, breathing threat.