This guide provides comprehensive instructions for creating and configuring game objects in the ReRightGame Unity project. Follow these specifications to ensure proper integration with the game's systems.
Configure these layers in Unity's Layer settings:
- Player: For the player character
- InteractableLayer: For NPCs and interactive objects
- SolidObjects: For walls, obstacles, and collision objects
Configure these tags in Unity's Tag Manager:
- Player: Player character identification
- NPC: Standard scripted NPCs
- NPC_AI: AI-powered NPCs with LLM integration
- Player_Interaction_Point: Player's interaction detection point
- Interactable: General interactable objects
- GameController: Main game controller object
- Tag:
NPC(for scripted NPCs) orNPC_AI(for AI-powered NPCs) - Layer:
InteractableLayer
-
NpcInit - Runtime component initialization
- Automatically creates Rigidbody2D (Kinematic)
- Sets up CapsuleCollider2D for character hitbox
- Creates interaction zones for player detection
- Configures physics properties
-
NPCController - Main NPC behavior controller
- Manages NPC states (Idle, Walking, Speaking)
- Handles interaction logic and dialog triggering
- Coordinates with movement and animation systems
- Implements
Interactable_intfinterface
-
CharacterAnimator - Sprite-based animation system
- Manages 4-directional movement animations
- Requires sprite lists for each direction (up, down, left, right)
- Coordinates with movement system for animation state
-
CharacterMove - Universal movement controller
- Handles smooth grid-based movement
- Integrates with collision detection system
- Manages movement state and coordination
-
CollisionDetector - Movement collision detection
- Prevents NPCs from walking into obstacles or other characters
- Manages collision state for movement coordination
- Essential for proper NPC pathfinding and movement validation
- Works with CharacterMove to ensure smooth navigation
-
LLM_NPCController - AI integration controller (NPC_AI only)
- Required only for NPCs with
NPC_AItag - Manages LLM communication and response generation
- Not needed for standard scripted NPCs with
NPCtag
- Required only for NPCs with
- Create new GameObject
- Set tag to
NPCorNPC_AIbased on requirements - Set layer to
InteractableLayer - Add all required scripts listed above
- Configure sprite animations in CharacterAnimator
- Set up walking patterns in NPCController (optional)
- Assign dialog content for conversations
- Tag:
Player - Layer:
Player
-
PlayerInit - Runtime component initialization
- Creates Rigidbody2D (Kinematic) for player physics
- Sets up CapsuleCollider2D for character representation
- Creates interaction point child object for world interaction
- Configures collision detection and interaction zones
-
PlayerController - Input handling and game interaction
- Processes user input (WASD/Arrow keys for movement, E for interaction)
- Manages movement validation and execution
- Handles interaction detection and triggering
- Coordinates with dialog system for conversations
-
CharacterMove - Shared movement system
- Same movement controller used by NPCs for consistency
- Handles smooth interpolation and collision detection
- Manages movement state and physics integration
-
CharacterAnimator - Sprite-based animation
- Same animation system as NPCs
- Requires directional sprite configuration
- Provides visual feedback for movement direction
- Create new GameObject
- Set tag to
Player - Set layer to
Player - Add all required scripts
- Configure sprite animations for all movement directions
- Ensure proper input configuration in Unity Input settings
- Tag:
GameController - Layer:
Default
-
GameLayers - Layer management system
- Singleton providing global access to Unity layers
- Configures layer masks for collision detection
- Essential for physics system integration
-
GameController - Main game state manager
- Manages game states (freeRoam vs dialogMode)
- Coordinates between player and dialog systems
- Handles state transitions and input routing
-
AuthManager - IPC authentication system [CRITICAL REQUIREMENT]
- Manages secure communication between Unity and Python server
- Generates dynamic secrets and authentication tokens
- Provides IPC-based credential exchange via named pipes
- MUST be attached - AI communication will fail without this component
-
DialogManager - Conversation system controller
- Singleton managing all dialog interactions
- Handles UI presentation and user input
- Integrates with both scripted and AI conversations
-
ServerSocketC - Network communication manager
- Singleton managing Python server communication
- Handles TCP connections for AI NPCs with mandatory authentication
- Manages server lifecycle and connection pooling
- Depends on AuthManager for all AI communications
-
Hasher - Connection management system
- Maps NPC GUIDs to network connections
- Manages connection lifecycle and cleanup
- Essential for multi-NPC AI communication
-
Killports - Development utility
- Network debugging and cleanup utility
- Prevents port conflicts during development
- Development-specific tooling
- Create new GameObject named "GameController"
- Set tag to
GameController - Set layer to
Default - Add all required scripts (including AuthManager - CRITICAL)
- Verify AuthManager is attached - Check component is present before proceeding
- Configure references in GameController script (PlayerController, Camera)
- Set up UI references in DialogManager (dialog box, text components)
- Configure layer masks in GameLayers component
- Test authentication setup - Verify AuthManager initializes before ServerSocketC
- AuthManager MUST be attached to GameController before any AI operations
- Game will fail to start Python server without proper AuthManager setup
- No fallback mode available - authentication is mandatory for all AI communications
- Initialization order: AuthManager → ServerSocketC → Python server startup
Purpose: Universal movement system shared by player and NPCs
- Grid-based movement with smooth interpolation
- Collision detection and validation
- Integration with animation and physics systems
- Movement state management for other systems
Purpose: Sprite-based 4-directional animation system
- Manages sprite sequences for each movement direction
- Coordinates with movement system for state synchronization
- Provides visual feedback for character direction and movement
Purpose: Movement collision detection system for NPCs
- Prevents NPCs from walking into obstacles, walls, or other characters
- Manages collision state flags for movement coordination
- Integrates with CharacterMove to validate movement paths
- Essential for proper NPC navigation and pathfinding behavior
Purpose: Main NPC behavior coordinator
- State machine managing NPC behavior (Idle/Walking/Speaking)
- Interaction detection and dialog triggering
- Integration with AI systems for dynamic conversations
- Event system for coordinating with other systems
Purpose: AI integration and conversation management
- Singleton service for LLM communication
- Context-aware conversation generation
- Network communication with Python LLM server
- Personality generation and dialog formatting
Purpose: Runtime component initialization for NPCs
- Programmatic creation of physics components
- Interaction zone setup and configuration
- Collision detection setup for proper game integration
Purpose: User input processing and world interaction
- Input handling for movement and interaction
- Physics-based movement validation
- Interaction detection and system coordination
- Integration with dialog system for conversations
Purpose: Runtime component setup for player character
- Physics component creation and configuration
- Interaction point setup for world interaction
- Collision detection configuration
Purpose: Central game state management
- Game state coordination (exploration vs conversation)
- Input routing between different systems
- State transition management
Purpose: Conversation system coordination
- UI management for dialog presentation
- Integration between scripted and AI conversations
- User input handling for conversation progression
Purpose: Unity layer management
- Centralized access to collision layers
- Physics query configuration
- Layer mask management for different systems
- All characters must be on appropriate layers for collision detection
- Interaction zones require proper tag configuration
- Movement validation depends on correct layer assignment
- NPCs with
NPC_AItag automatically establish server connections - LLM_NPCController manages conversation context and personality
- Network communication requires proper server setup
- All interactive objects must implement
Interactable_intf - Dialog system coordinates with game state management
- Both scripted and AI conversations use the same interface
- Shared components reduce memory overhead
- Singleton patterns provide efficient global access
- Event-driven architecture minimizes coupling
- Ensure all required scripts are attached
- Verify proper tag and layer assignment
- Check script execution order dependencies
- Verify layer configuration matches collision detection
- Ensure proper collider setup and sizing
- Check that GameLayers component is configured
- Confirm NPC_AI tag for AI-powered characters
- Verify server connection establishment
- Check LLM_NPCController singleton initialization
This guide ensures proper component setup for seamless integration with the ReRightGame's sophisticated character and AI systems.