Link to game: https://gman17.itch.io/week-62
This system makes enemies move away from the player when inside a specified radius. Movement is restricted to allowed tiles on the tilemap, and enemies prioritize avoidance points based on their relative position (left or right) to the player.
- Dynamic Avoidance: Enemies avoid the player based on their position.
- Tile Validation: Moves only on allowed tiles.
- Configurable Settings: Adjust radius, speed, angles, and logs in the Inspector.
- Debugging Tools: Enable logs for movement, tile checks, and detection.
- Purpose: Detects enemies and calculates avoidance points.
- Key Settings:
- avoidRadius: Avoidance detection radius.
- angleStep: Step size for rotating to find valid tiles.
- maxAttempts: Maximum angles to test for valid points.
- logAvoidance: Toggle logs in the Inspector.
- Purpose: Moves enemies toward the target avoidance point.
- Key Settings:
- speed: Movement speed toward the target.
- stoppingDistance: Minimum distance to stop at the target.
- logMovement: Toggle logs in the Inspector.
- Enemy Detection:
- Finds enemies within the radius using OverlapCircleAll.
- Avoidance Point Calculation:
- Determines if the enemy is on the left or right of the player.
- Searches for the first valid tile by rotating outward in steps.
- Movement:
- Moves smoothly to the target while validating tiles.
- Attach EnemyAvoidance.cs to the Player.
- Attach EnemyMover.cs to each Enemy.
- Assign Tilemap, Allowed Tiles, and Enemy Layer in the Inspector.
- Adjust settings like radius, angle step, and speed as needed.