You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
[CreateAssetMenu(menuName = "Abilities/Vector Fence Ability")]
|
|
public class VectorFenceAbility : Ability
|
|
{
|
|
[Header("Vector Fence Settings")]
|
|
public float wallLength = 8f;
|
|
public float wallWidth = 0.5f;
|
|
public float wallHeight = 1f;
|
|
public float scaleUpDuration = 1.0f;
|
|
public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
|
|
{
|
|
if (!NetworkManager.Singleton.IsServer)
|
|
{
|
|
Debug.LogError("[VectorFenceAbility] Execute should only be called on the server.");
|
|
return;
|
|
}
|
|
|
|
if (character == null)
|
|
{
|
|
Debug.LogError("[VectorFenceAbility] ServerCharacter is null.");
|
|
return;
|
|
}
|
|
|
|
// Calculate wall placement based on target position and forward direction
|
|
Vector3 forward = character.transform.forward;
|
|
Vector3 wallCenter = targetPosition;
|
|
|
|
GameObject wallInstance = Instantiate(prefab, wallCenter, Quaternion.identity);
|
|
wallInstance.transform.eulerAngles = targetRotation;
|
|
if (wallInstance.TryGetComponent(out NetworkObject networkObject))
|
|
{
|
|
networkObject.Spawn();
|
|
Debug.Log($"[VectorFenceAbility] Wall spawned at {wallCenter} facing {forward}.");
|
|
}
|
|
}
|
|
}
|