* Source: Get monster models from Unity Asset Store.
* Source: Get monster models from Unity Asset Store.
-**Technical Details**
-**Technical Details**
* Random Generation
***Player input acquisition and movement logic**
+ Use empty objects in the scene as generation points, and implement random generation logic of crystals and monsters through scripts.
+ Use Unity's Input System to unify management, combine with Cinemachine components to achieve perspective control, and use Rigidbody components to control the movement of characters.
***Monster AI**
+ Main functions include:
+ Monster behavior is implemented based on the Unity NavMesh system, covering patrol path planning and dynamic target tracking.
* Input management
+ Monsters use state machines to achieve states in different situations, such as standby state (patrol), normal pursuit state (the player has not picked up the crystal yet), and global pursuit state (the player has picked up the crystal).
+ Use Input System to create a custom input action set to handle player movement and UI operations respectively.
* Character state management
+ A state system designed based on a finite state machine, in which PlayerMovingState is responsible for handling movement logic.
* Movement implementation
+ Use the camera direction to dynamically calculate the movement direction, and update the character's position and orientation through the rigid body to ensure that the physical performance of the player's movement is realistic and smooth.
+ This module implements the monster spawning and patrol logic through the following steps:
* Spawning position and patrol target initialization
+ Place multiple empty objects in the scene as monster spawning points and patrol target points respectively. Load these points into the list through code for subsequent logic use.
* Monster spawning logic
+ According to the preset number of monsters, randomly select spawning points from the spawning point list and instantiate monsters at the corresponding coordinate positions. Each generated monster comes with a patrol point list for subsequent patrol logic use.
* Patrol logic
+ The monster's initial state is patrol mode (standby state), and navigation is implemented using NavMeshAgent. The monster randomly selects target points from the patrol point list and navigates to the target points one by one.
* State switching logic
+ During the patrol, the monster will constantly detect whether the player has entered its detection range (determined by distance and angle). If the player enters the range, the current monster will switch to the pursuit state. Under certain conditions (the player obtains the crystal), all monsters switch to the pursuit state.
+ Keycode
* Monster generation and patrol target initialization
* Generates a crystal by randomly selecting a point from the preset generation points.
+ Crystal picking:
* When the player touches the crystal, the interactive UI is displayed. After the player presses the interaction key, the crystal is destroyed and subsequent events are triggered.
+ Trigger event:
* After the crystal is picked up, the logic of the monster's global pursuit will be triggered.