PetIdleState - jimdroberts/FishMMO GitHub Wiki

Description

AI state for pet idle behavior. Handles following owner, path correction, and idle logic for pets.


API Access

Methods

  • public override void Enter(AIController controller)

    Called when entering the Pet Idle state. Sets agent speed to run. Parameters: - AIController controller: The AI controller.*

  • public override void Exit(AIController controller)

    Called when exiting the Pet Idle state. No cleanup needed by default. Parameters: - AIController controller: The AI controller.*

  • public override void UpdateState(AIController controller, float deltaTime)

    Called every frame to update the Pet Idle state. Handles owner following and path correction. Parameters: - AIController controller: The AI controller. - float deltaTime: Frame time.*


Basic Usage

Setup

  1. Create a new PetIdleState asset via the Unity Editor (Assets > Create > FishMMO > Character > NPC > AI > Pet Idle State).
  2. Assign the state to an AIController for pet NPCs that require idle/following behavior.
  3. Ensure the Pet component and PetOwner references are set up correctly.

Example

// Example 1: Assigning the Pet Idle state to an AI controller
AIController ai = ...;
PetIdleState petIdleState = ...;
ai.ChangeState(petIdleState);

// Example 2: Customizing follow distance or logic in PetIdleState
// Override UpdateState for custom behavior

Best Practices

  • Ensure Pet and PetOwner references are valid for correct following behavior.
  • Use NavMesh path checks to handle path correction and warping as needed.
  • Adjust follow distance and idle logic for different pet types.
  • Document custom AI state logic for maintainability and clarity.
⚠️ **GitHub.com Fallback** ⚠️