Cleaner Code

dev-main
Ali Sharoz 4 days ago
parent 6fdbf52440
commit 3f97f20e72

@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 3764456690617734740}
- component: {fileID: 2500946308868101064}
- component: {fileID: 1322199249233456991}
- component: {fileID: 1325380290019009501}
m_Layer: 0
m_Name: WallAbilityIndicator
m_TagString: Untagged
@ -26,7 +27,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894374618083898175}
serializedVersion: 2
m_LocalRotation: {x: -0, y: 0.5913096, z: -0, w: 0.8064447}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.958935, y: 3.7648613e-17, z: 6.871315}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -83,3 +84,18 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &1325380290019009501
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3894374618083898175}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e19747de3f5aca642ab2be37e372fb86, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
m_EffectDistance: {x: 1, y: -1}
m_UseGraphicAlpha: 1

@ -264,7 +264,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: GlobalObjectIdHash
value: 3737985212
value: 3177087589
objectReference: {fileID: 0}
- target: {fileID: 4600110157238723790, guid: 0d2d836e2e83b754fa1a1c4022d6d65d, type: 3}
propertyPath: PrefabHashGenerator
@ -846,6 +846,10 @@ MonoBehaviour:
playerLayer:
serializedVersion: 2
m_Bits: 8
mouseMoveThreshold: 0.1
VectorWallLayerMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &4321537148236331373
MonoBehaviour:
m_ObjectHideFlags: 0

@ -1357,6 +1357,111 @@ MonoBehaviour:
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 0
--- !u!1 &734818076
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 734818077}
- component: {fileID: 734818080}
- component: {fileID: 734818079}
- component: {fileID: 734818078}
m_Layer: 8
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &734818077
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734818076}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.296, y: -1, z: 0.0852}
m_LocalScale: {x: 12.04426, y: 0.1, z: 10.169825}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3605442766607006888}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &734818078
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734818076}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &734818079
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734818076}
m_Enabled: 0
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &734818080
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 734818076}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &772015876
MonoBehaviour:
m_ObjectHideFlags: 0
@ -8936,11 +9041,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.y
value: 0.3097298
value: 0.30972984
objectReference: {fileID: 0}
- target: {fileID: 1676734516695783279, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalRotation.z
value: -0.14506969
value: -0.1450697
objectReference: {fileID: 0}
- target: {fileID: 1676734516724634599, guid: 0193228de87741d40a42e561901c9083, type: 3}
propertyPath: m_LocalPosition.z
@ -118031,9 +118136,10 @@ Transform:
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.6894, y: 0.17, z: 1.6894}
m_LocalScale: {x: 1.6894, y: 0.17, z: 2.1908138}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 734818077}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3605442766607006889

@ -32,6 +32,7 @@ public class AbilitySystem : NetworkBehaviour
private bool isWallPlacementStarted = false;
private bool isValidPlacement = true;
NavMeshAgent m_Agent;
private void Awake()
{
m_Agent = GetComponent<NavMeshAgent>();
@ -115,7 +116,8 @@ public class AbilitySystem : NetworkBehaviour
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
{
wallIndicator.transform.position = hit.point; // Update position to follow the mouse
//wallIndicator.transform.position = hit.point; // Update position to follow the mouse
wallIndicator.transform.position = new Vector3(hit.point.x, 0, hit.point.z);
//isValidPlacement = true;
//AliSharoz
@ -135,7 +137,7 @@ public class AbilitySystem : NetworkBehaviour
{
//if (isValidPlacement)
{
wallSpawnPosition = hit.point; // Save spawn position
wallSpawnPosition = new Vector3( hit.point.x,0, hit.point.z); // Save spawn position
initialMousePosition = Input.mousePosition; // Store the initial mouse position on click
isWallPlacementStarted = true;
Debug.Log($"[AbilitySystem] Wall placement started at {wallSpawnPosition}");
@ -195,13 +197,15 @@ public class AbilitySystem : NetworkBehaviour
Ray ray = Camera.main.ScreenPointToRay(currentMousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
Vector3 direction = (hit.point - wallIndicator.transform.position).normalized;
Vector3 direction = (new Vector3( hit.point.x,0, hit.point.z) - wallIndicator.transform.position).normalized;
float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
angle -= 90f;
Quaternion targetRotation = Quaternion.Euler(0f, angle, 0f);
// Smooth rotation with Lerp
// wallIndicator.transform.rotation = targetRotation;
wallIndicator.transform.rotation = Quaternion.Lerp(wallIndicator.transform.rotation, targetRotation, Time.deltaTime * wallRotationSpeed);
wallIndicator.transform.rotation = Quaternion.Lerp(wallIndicator.transform.rotation, targetRotation, 0.5f);
//wallIndicator.transform.rotation = Quaternion.Lerp(wallIndicator.transform.rotation, targetRotation, Time.deltaTime * wallRotationSpeed);
isValidPlacement = IsPlacementValid(wallIndicator.transform.position, wallIndicator.transform.rotation, playerLayer);
/*
@ -369,7 +373,7 @@ public class AbilitySystem : NetworkBehaviour
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
{
currentAbilityIndicator.transform.position = hit.point;
currentAbilityIndicator.transform.position = new Vector3(hit.point.x, 0, hit.point.z);
currentAbilityIndicator.transform.localScale = Vector3.one * activeAbility.abilityRadius;
}
}

Loading…
Cancel
Save