Fixed the ability not syncing issue
parent
bf8350d7be
commit
3c21407c2c
@ -1,43 +1,11 @@
|
||||
using UnityEngine;
|
||||
using Unity.Netcode;
|
||||
|
||||
[CreateAssetMenu(menuName = "Abilities/Slow Zone Ability")]
|
||||
public class SlowZoneAbility : Ability
|
||||
{
|
||||
[Header("Slow Zone Settings")]
|
||||
public GameObject slowZonePrefab;
|
||||
|
||||
protected override void Activate(GameObject owner)
|
||||
{
|
||||
Camera mainCamera = Camera.main;
|
||||
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit))
|
||||
{
|
||||
Vector3 spawnPosition = hit.point;
|
||||
|
||||
if (owner.TryGetComponent(out NetworkObject networkOwner))
|
||||
{
|
||||
SpawnSlowZoneServerRpc(spawnPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Rpc(SendTo.Server)]
|
||||
private void SpawnSlowZoneServerRpc(Vector3 position)
|
||||
{
|
||||
GameObject slowZone = Instantiate(slowZonePrefab, position, Quaternion.identity);
|
||||
slowZone.GetComponent<NetworkObject>().Spawn();
|
||||
slowZone.GetComponent<SlowZonePrefab>().Ability = this;
|
||||
Debug.Log($"Slow Zone spawned at {position}.");
|
||||
}
|
||||
|
||||
|
||||
public override void OnDrawAbilityGizmos(Vector3 pos)
|
||||
{
|
||||
Gizmos.color = new Color(0f, 0.5f, 1f, 0.2f); // Light blue with transparency
|
||||
Gizmos.DrawSphere(pos, abilityRadius);
|
||||
// No direct logic here, spawning is handled in AbilitySystem
|
||||
Debug.Log($"SlowZoneAbility activated by {owner.name}.");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue