Organize custom scripts under Assets/Baba_yaga and merge Opsive folders to Assets root

This commit is contained in:
2026-07-01 20:32:28 +07:00
parent 83d4157ac6
commit befc19bf37
5901 changed files with 243 additions and 141 deletions

View File

@@ -0,0 +1,62 @@
/// ---------------------------------------------
/// Ultimate Character Controller
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Demo.AI
{
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Game;
using Opsive.UltimateCharacterController.Utility;
using UnityEngine;
/// <summary>
/// Enables the attack on the agent when the character enters the trigger.
/// </summary>
public class AttackTrigger : MonoBehaviour
{
[Tooltip("The agent doing the attacking.")]
[SerializeField] protected MeleeAgent m_Agent;
/// <summary>
/// An object has exited the trigger.
/// </summary>
/// <param name="other">The collider that exited the trigger.</param>
private void OnTriggerEnter(Collider other)
{
// A main character collider is required.
if (!MathUtility.InLayerMask(other.gameObject.layer, 1 << LayerManager.Character)) {
return;
}
// The object must be a character.
var characterLocomotion = other.GetComponentInParent<UltimateCharacterLocomotion>();
if (characterLocomotion == null) {
return;
}
m_Agent.Attack();
}
/// <summary>
/// An object has entered the trigger.
/// </summary>
/// <param name="other">The object that entered the trigger.</param>
private void OnTriggerExit(Collider other)
{
// A main character collider is required.
if (!MathUtility.InLayerMask(other.gameObject.layer, 1 << LayerManager.Character)) {
return;
}
// The object must be a character.
var characterLocomotion = other.GetComponentInParent<UltimateCharacterLocomotion>();
if (characterLocomotion == null) {
return;
}
m_Agent.CancelAttack();
}
}
}