Vector Wall bug fix

dev-main
Ali Sharoz 6 days ago
parent 1dd1430423
commit 11cc921c50

@ -122,7 +122,7 @@ NavMeshObstacle:
m_Extents: {x: 0.5, y: 0.5, z: 0.5}
m_MoveThreshold: 0.01
m_Carve: 1
m_CarveOnlyStationary: 0
m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0, z: 0}
m_TimeToStationary: 0.5
--- !u!114 &5807442085122568602

@ -8896,7 +8896,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.x
value: 0.3943448
value: 0.39434478
objectReference: {fileID: 0}
- target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.y
@ -8936,11 +8936,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.y
value: 0.30972984
value: 0.3097298
objectReference: {fileID: 0}
- target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.z
value: -0.1450697
value: -0.14506969
objectReference: {fileID: 0}
- target: {fileID: 1676734516724634599, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalPosition.z
@ -9161,15 +9161,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3}
propertyPath: m_LocalRotation.x
value: 0.39434484
value: 0.3943448
objectReference: {fileID: 0}
- target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3}
propertyPath: m_LocalRotation.y
value: 0.3104465
value: 0.31044647
objectReference: {fileID: 0}
- target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3}
propertyPath: m_LocalRotation.z
value: -0.1435298
value: -0.14352977
objectReference: {fileID: 0}
- target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
@ -281799,7 +281799,6 @@ SceneRoots:
- {fileID: 1124806920}
- {fileID: 1716740238}
- {fileID: 1060857731}
- {fileID: 3605442766607006888}
- {fileID: 451210157}
- {fileID: 1531756835}
- {fileID: 3765979715153886892}
@ -281816,3 +281815,4 @@ SceneRoots:
- {fileID: 7822537384937625691}
- {fileID: 1521032484}
- {fileID: 862711270}
- {fileID: 3605442766607006888}

@ -150,7 +150,7 @@ Transform:
m_GameObject: {fileID: 286165426}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: -1.04, y: 0, z: -0.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -419,7 +419,7 @@ Transform:
m_GameObject: {fileID: 1415641637}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.4553, y: -0.14, z: -1.0268}
m_LocalPosition: {x: 0.5847, y: -0.14, z: -0.10680002}
m_LocalScale: {x: 2.1429026, y: 1.2077, z: 2.595087}
m_ConstrainProportionsScale: 0
m_Children: []

@ -5,6 +5,8 @@ using Unity.BossRoom.Gameplay.GameplayObjects;
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using static Codice.Client.Common.WebApi.WebApiEndpoints;
public class AbilitySystem : NetworkBehaviour
{
@ -29,7 +31,11 @@ public class AbilitySystem : NetworkBehaviour
private Vector3 wallSpawnPosition;
private bool isWallPlacementStarted = false;
private bool isValidPlacement = true;
NavMeshAgent m_Agent;
private void Awake()
{
m_Agent = GetComponent<NavMeshAgent>();
}
void Update()
{
HandleAbilityMode();
@ -48,7 +54,7 @@ public class AbilitySystem : NetworkBehaviour
UpdateWallIndicatorPosition(); // Follow the mouse when ability is activated
}
if (Input.GetMouseButtonDown(0) && isValidPlacement)
if (Input.GetMouseButtonDown(0))//AliSharoz && isValidPlacement)
{
StartWallPlacement();
}
@ -67,6 +73,9 @@ public class AbilitySystem : NetworkBehaviour
}
else
{
UseActiveAbility(); // Place the wall when LMB is released
isWallPlacementStarted = false;
Invoke(nameof(RepositionAgent), 0.5f);
Debug.Log("Invalid placement! Cannot place wall on top of another player.");
}
}
@ -108,13 +117,15 @@ public class AbilitySystem : NetworkBehaviour
{
wallIndicator.transform.position = hit.point; // Update position to follow the mouse
//isValidPlacement = true;
//AliSharoz
isValidPlacement = IsPlacementValid(hit.point, wallIndicator.transform.rotation, playerLayer);
var meshRenderer = wallIndicator.GetComponent<MeshRenderer>();
if (meshRenderer != null)
{
meshRenderer.material = isValidPlacement ? validPlacementMaterial : invalidPlacementMaterial;
}
//var meshRenderer = wallIndicator.GetComponent<MeshRenderer>();
//if (meshRenderer != null)
//{
// meshRenderer.material = isValidPlacement ? validPlacementMaterial : invalidPlacementMaterial;
//}
}
}
@ -131,11 +142,45 @@ public class AbilitySystem : NetworkBehaviour
}
else
{
wallSpawnPosition = hit.point; // Save spawn position
initialMousePosition = Input.mousePosition; // Store the initial mouse position on click
isWallPlacementStarted = true;
Debug.Log("Cannot place the wall on top of another player.");
Invoke(nameof(RepositionAgent), 0.5f);
}
}
}
public float searchRadius = 5f;
private void RepositionAgent()
{
Debug.Log("RepositionAgent()1");
//if (NavMesh.SamplePosition(currentPosition, out hit, 0.01f, NavMesh.AllAreas))
//if (m_Agent.isOnNavMesh == false)
{
Debug.Log("RepositionAgent()2");
Vector3 currentPosition = m_Agent.transform.position;
NavMeshHit hit;
// Sample the nearest point on the NavMesh
if (NavMesh.SamplePosition(currentPosition, out hit, searchRadius, NavMesh.AllAreas))
{
Debug.Log("RepositionAgent()3");
Debug.Log($"Found nearest NavMesh point at {hit.position}");
m_Agent.Warp(hit.position); // Warp the agent to the nearest point without path recalculation
}
else
{
Debug.Log("RepositionAgent()4");
Debug.LogError("No walkable NavMesh point found within the search radius!");
}
}
//else
//{
// Debug.LogWarning("No valid NavMesh point found near the agent!");
//}
}
private void RotateWallIndicator()
{
if (isWallPlacementStarted && wallIndicator != null)
@ -162,15 +207,18 @@ public class AbilitySystem : NetworkBehaviour
isValidPlacement = IsPlacementValid(wallIndicator.transform.position, wallIndicator.transform.rotation, playerLayer);
// Change indicator color based on placement validity
var meshRenderer = wallIndicator.GetComponent<MeshRenderer>();
if (meshRenderer != null)
{
meshRenderer.material = isValidPlacement ? validPlacementMaterial : invalidPlacementMaterial;
}
//AliSharoz
//var meshRenderer = wallIndicator.GetComponent<MeshRenderer>();
//if (meshRenderer != null)
//{
// meshRenderer.material = isValidPlacement ? validPlacementMaterial : invalidPlacementMaterial;
//}
if (!isValidPlacement)
{
Debug.Log("Cannot rotate wall here: Overlapping with another object.");
Invoke(nameof(RepositionAgent), 0.5f);
}
}
}

@ -240,8 +240,8 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character
m_CharLogic.MovementStatus.Value = currentState;
m_PreviousState = currentState;
}
}
}
public override void OnNetworkDespawn()
{
if (m_NavPath != null)

Loading…
Cancel
Save