using UnityEngine; [CreateAssetMenu(menuName = "Abilities/Freeze Shard")] public class FreezeShardAbility : Ability { public GameObject projectilePrefab; public float speed = 20f; public float damage = 0f; // optional direct damage public float freezeDuration = 3f; public float lifeTime = 4f; public float spawnOffset = 0.5f; public override void Activate(AbilityUser user) { if (!user || !projectilePrefab) return; var pos = user.CastPos() + user.Forward() * spawnOffset; var rot = Quaternion.LookRotation(user.Forward()); var go = Instantiate(projectilePrefab, pos, rot); var rb = go.GetComponent(); if (rb) rb.velocity = user.Forward() * speed; var shard = go.GetComponent(); if (!shard) shard = go.AddComponent(); shard.damage = damage; shard.freezeDuration = freezeDuration; shard.ownerRoot = user.transform; var projCol = go.GetComponent(); if (projCol) { foreach (var oc in user.GetComponentsInChildren()) Physics.IgnoreCollision(projCol, oc, true); } Destroy(go, lifeTime); } }