Skip to content

Commit 667eaf2

Browse files
committed
Add path visualizer system to vehicles
Introduces PathVisualizer script, material, and arrow icon for visualizing movement paths. Updates Infantry, OrnithopterA, OrnithopterB, Quad, and TankCombat prefabs to include LineRenderer and PathVisualizer components. Adjusts atmosphere, cloud, and fog materials for sun direction consistency.
1 parent bdc4ebe commit 667eaf2

21 files changed

+1513
-26
lines changed

Red Strike/Assets/Icons/Arrow.png

14.4 KB
Loading

Red Strike/Assets/Icons/Arrow.png.meta

Lines changed: 130 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: PVMaterial
11+
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
12+
m_Parent: {fileID: 0}
13+
m_ModifiedSerializedProperties: 0
14+
m_ValidKeywords:
15+
- _SURFACE_TYPE_TRANSPARENT
16+
m_InvalidKeywords: []
17+
m_LightmapFlags: 4
18+
m_EnableInstancingVariants: 0
19+
m_DoubleSidedGI: 0
20+
m_CustomRenderQueue: 3000
21+
stringTagMap:
22+
RenderType: Transparent
23+
disabledShaderPasses:
24+
- MOTIONVECTORS
25+
- DepthOnly
26+
- SHADOWCASTER
27+
m_LockedProperties:
28+
m_SavedProperties:
29+
serializedVersion: 3
30+
m_TexEnvs:
31+
- _BaseMap:
32+
m_Texture: {fileID: 2800000, guid: 7a7b7921e01ee754890d903f7834b7b2, type: 3}
33+
m_Scale: {x: 1, y: 1}
34+
m_Offset: {x: 0, y: 0}
35+
- _BumpMap:
36+
m_Texture: {fileID: 0}
37+
m_Scale: {x: 1, y: 1}
38+
m_Offset: {x: 0, y: 0}
39+
- _DetailAlbedoMap:
40+
m_Texture: {fileID: 0}
41+
m_Scale: {x: 1, y: 1}
42+
m_Offset: {x: 0, y: 0}
43+
- _DetailMask:
44+
m_Texture: {fileID: 0}
45+
m_Scale: {x: 1, y: 1}
46+
m_Offset: {x: 0, y: 0}
47+
- _DetailNormalMap:
48+
m_Texture: {fileID: 0}
49+
m_Scale: {x: 1, y: 1}
50+
m_Offset: {x: 0, y: 0}
51+
- _EmissionMap:
52+
m_Texture: {fileID: 0}
53+
m_Scale: {x: 1, y: 1}
54+
m_Offset: {x: 0, y: 0}
55+
- _MainTex:
56+
m_Texture: {fileID: 2800000, guid: 7a7b7921e01ee754890d903f7834b7b2, type: 3}
57+
m_Scale: {x: 1, y: 1}
58+
m_Offset: {x: 0, y: 0}
59+
- _MetallicGlossMap:
60+
m_Texture: {fileID: 0}
61+
m_Scale: {x: 1, y: 1}
62+
m_Offset: {x: 0, y: 0}
63+
- _OcclusionMap:
64+
m_Texture: {fileID: 0}
65+
m_Scale: {x: 1, y: 1}
66+
m_Offset: {x: 0, y: 0}
67+
- _ParallaxMap:
68+
m_Texture: {fileID: 0}
69+
m_Scale: {x: 1, y: 1}
70+
m_Offset: {x: 0, y: 0}
71+
- _SpecGlossMap:
72+
m_Texture: {fileID: 0}
73+
m_Scale: {x: 1, y: 1}
74+
m_Offset: {x: 0, y: 0}
75+
- unity_Lightmaps:
76+
m_Texture: {fileID: 0}
77+
m_Scale: {x: 1, y: 1}
78+
m_Offset: {x: 0, y: 0}
79+
- unity_LightmapsInd:
80+
m_Texture: {fileID: 0}
81+
m_Scale: {x: 1, y: 1}
82+
m_Offset: {x: 0, y: 0}
83+
- unity_ShadowMasks:
84+
m_Texture: {fileID: 0}
85+
m_Scale: {x: 1, y: 1}
86+
m_Offset: {x: 0, y: 0}
87+
m_Ints: []
88+
m_Floats:
89+
- _AddPrecomputedVelocity: 0
90+
- _AlphaClip: 0
91+
- _AlphaToMask: 0
92+
- _Blend: 0
93+
- _BlendModePreserveSpecular: 1
94+
- _BlendOp: 0
95+
- _BumpScale: 1
96+
- _ClearCoatMask: 0
97+
- _ClearCoatSmoothness: 0
98+
- _Cull: 2
99+
- _Cutoff: 0.5
100+
- _DetailAlbedoMapScale: 1
101+
- _DetailNormalMapScale: 1
102+
- _DstBlend: 10
103+
- _DstBlendAlpha: 10
104+
- _EnvironmentReflections: 1
105+
- _GlossMapScale: 0
106+
- _Glossiness: 0
107+
- _GlossyReflections: 0
108+
- _Metallic: 0
109+
- _OcclusionStrength: 1
110+
- _Parallax: 0.005
111+
- _QueueOffset: 0
112+
- _ReceiveShadows: 1
113+
- _SampleGI: 0
114+
- _Smoothness: 0.5
115+
- _SmoothnessTextureChannel: 0
116+
- _SpecularHighlights: 1
117+
- _SrcBlend: 5
118+
- _SrcBlendAlpha: 1
119+
- _Surface: 1
120+
- _WorkflowMode: 1
121+
- _ZWrite: 0
122+
m_Colors:
123+
- _BaseColor: {r: 0.14833164, g: 1, b: 0, a: 1}
124+
- _Color: {r: 0.14833161, g: 1, b: 0, a: 1}
125+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
126+
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
127+
m_BuildTextureStacks: []
128+
m_AllowLocking: 1
129+
--- !u!114 &3695829550287666465
130+
MonoBehaviour:
131+
m_ObjectHideFlags: 11
132+
m_CorrespondingSourceObject: {fileID: 0}
133+
m_PrefabInstance: {fileID: 0}
134+
m_PrefabAsset: {fileID: 0}
135+
m_GameObject: {fileID: 0}
136+
m_Enabled: 1
137+
m_EditorHideFlags: 0
138+
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
139+
m_Name:
140+
m_EditorClassIdentifier:
141+
version: 10

Red Strike/Assets/InputController/PVMaterial.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using UnityEngine;
2+
using UnityEngine.AI;
3+
4+
namespace InputController
5+
{
6+
[RequireComponent(typeof(LineRenderer))]
7+
public class PathVisualizer : MonoBehaviour
8+
{
9+
private LineRenderer lineRenderer;
10+
private NavMeshAgent agent;
11+
private Material lineMaterial;
12+
13+
private int baseMapID;
14+
15+
[Header("Görsel Ayarlar")]
16+
public float animationSpeed = 3.0f;
17+
public float lineWidth = 1.0f;
18+
public float textureTilingMultiplier = 0.5f;
19+
20+
public enum PathColor { Red, Green, Yellow }
21+
22+
private void Awake()
23+
{
24+
lineRenderer = GetComponent<LineRenderer>();
25+
agent = GetComponent<NavMeshAgent>();
26+
27+
lineRenderer.startWidth = lineWidth;
28+
lineRenderer.endWidth = lineWidth;
29+
lineRenderer.enabled = false;
30+
31+
lineRenderer.numCornerVertices = 4;
32+
lineRenderer.numCapVertices = 4;
33+
34+
lineMaterial = lineRenderer.material;
35+
baseMapID = Shader.PropertyToID("_BaseMap");
36+
37+
}
38+
39+
private void Update()
40+
{
41+
if (lineRenderer.enabled && lineMaterial != null)
42+
{
43+
float offset = Time.time * -animationSpeed;
44+
Vector2 offsetVec = new Vector2(offset, 0);
45+
46+
lineMaterial.SetTextureOffset(baseMapID, offsetVec);
47+
}
48+
}
49+
50+
public void ShowNavMeshPath(PathColor color)
51+
{
52+
if (agent == null || !agent.hasPath)
53+
{
54+
HidePath();
55+
return;
56+
}
57+
58+
Vector3[] corners = agent.path.corners;
59+
if (corners.Length < 2)
60+
{
61+
HidePath();
62+
return;
63+
}
64+
65+
DrawLineInternal(corners, color);
66+
}
67+
68+
public void ShowDirectLine(Vector3 start, Vector3 end, PathColor color)
69+
{
70+
Vector3[] points = new Vector3[] { start, end };
71+
DrawLineInternal(points, color);
72+
}
73+
74+
private void DrawLineInternal(Vector3[] points, PathColor color)
75+
{
76+
lineRenderer.enabled = true;
77+
lineRenderer.startWidth = lineWidth;
78+
lineRenderer.endWidth = lineWidth;
79+
80+
switch (color)
81+
{
82+
case PathColor.Red: lineMaterial.color = Color.red; break;
83+
case PathColor.Green: lineMaterial.color = Color.green; break;
84+
case PathColor.Yellow: lineMaterial.color = Color.yellow; break;
85+
}
86+
87+
for (int i = 0; i < points.Length; i++)
88+
{
89+
points[i].y += 0.5f;
90+
}
91+
92+
lineRenderer.positionCount = points.Length;
93+
lineRenderer.SetPositions(points);
94+
95+
float totalDist = 0;
96+
for (int i = 0; i < points.Length - 1; i++)
97+
{
98+
totalDist += Vector3.Distance(points[i], points[i + 1]);
99+
}
100+
101+
float finalTiling = totalDist * textureTilingMultiplier;
102+
if (finalTiling < 1.0f) finalTiling = 1.0f;
103+
104+
Vector2 scaleVec = new Vector2(finalTiling, 1);
105+
106+
lineMaterial.SetTextureScale(baseMapID, scaleVec);
107+
}
108+
109+
public void HidePath()
110+
{
111+
if (lineRenderer != null) lineRenderer.enabled = false;
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)