PetIdleState - jimdroberts/FishMMO GitHub Wiki
AI state for pet idle behavior. Handles following owner, path correction, and idle logic for pets.
-
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.*
- Create a new PetIdleState asset via the Unity Editor (Assets > Create > FishMMO > Character > NPC > AI > Pet Idle State).
- Assign the state to an AIController for pet NPCs that require idle/following behavior.
- Ensure the Pet component and PetOwner references are set up correctly.
// 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
- 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.