Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ColdShot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15박보승
ColdShot
Commits
8cfc3dea
Commit
8cfc3dea
authored
Jan 16, 2020
by
15박보승
Committed by
18류지석
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Greedy Pathfinding 구현
parent
07116f74
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
352 additions
and
33 deletions
+352
-33
NodalPathfinding2D.cs
Assets/NodalPathfinding2D.cs
+153
-27
NodalPathfinding2DAgent.cs
Assets/NodalPathfinding2DAgent.cs
+57
-0
NodalPathfinding2DAgent.cs.meta
Assets/NodalPathfinding2DAgent.cs.meta
+11
-0
NodalPathfinding2DEditor.cs
Assets/NodalPathfinding2DEditor.cs
+2
-0
Pathfinding.unity
Assets/Pathfinding.unity
+129
-6
No files found.
Assets/NodalPathfinding2D.cs
View file @
8cfc3dea
This diff is collapsed.
Click to expand it.
Assets/NodalPathfinding2DAgent.cs
0 → 100644
View file @
8cfc3dea
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
namespace
BS
{
public
class
NodalPathfinding2DAgent
:
MonoBehaviour
{
public
NodalPathfinding2D
pathFinder
;
public
Vector3
destination
;
public
List
<
Vector3
>
path
=
new
List
<
Vector3
>();
float
t
=
0.5f
;
private
void
OnDrawGizmos
()
{
Gizmos
.
color
=
Color
.
white
;
if
(
path
.
Count
>
0
)
{
Gizmos
.
DrawLine
(
transform
.
position
,
path
[
0
]);
for
(
int
i
=
0
;
i
<
path
.
Count
-
1
;
i
++)
{
Gizmos
.
DrawLine
(
path
[
i
]
+
new
Vector3
(
0
,
0
,
1
),
path
[
i
+
1
]
+
new
Vector3
(
0
,
0
,
1
));
}
Gizmos
.
color
=
Color
.
red
;
Gizmos
.
DrawSphere
(
destination
,
0.5f
);
}
}
private
void
Update
()
{
t
-=
Time
.
deltaTime
;
if
(
t
<
0
)
{
MoveTo
(
new
Vector2
(
Random
.
Range
(
pathFinder
.
bounds
.
min
.
x
,
pathFinder
.
bounds
.
max
.
x
),
Random
.
Range
(
pathFinder
.
bounds
.
min
.
y
,
pathFinder
.
bounds
.
max
.
y
)));
t
=
0.5f
;
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
))
{
transform
.
position
=
new
Vector2
(
Random
.
Range
(
pathFinder
.
bounds
.
min
.
x
,
pathFinder
.
bounds
.
max
.
x
),
Random
.
Range
(
pathFinder
.
bounds
.
min
.
y
,
pathFinder
.
bounds
.
max
.
y
));
}
if
(
Input
.
GetMouseButtonDown
(
1
))
{
MoveTo
(
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
));
}
//path = pathFinder.GetPathGreedy(transform.position, destination);
}
public
void
MoveTo
(
Vector3
destination
)
{
this
.
destination
=
destination
;
path
=
pathFinder
.
GetPathGreedy
(
transform
.
position
,
destination
);
}
}
}
\ No newline at end of file
Assets/NodalPathfinding2DAgent.cs.meta
0 → 100644
View file @
8cfc3dea
fileFormatVersion: 2
guid: f4a5a47a8846b8940a9edd3801d55993
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/NodalPathfinding2DEditor.cs
View file @
8cfc3dea
...
...
@@ -14,10 +14,12 @@ public class NodalPathfinding2DEditor : Editor
if
(
GUILayout
.
Button
(
"Bake"
))
{
myTarget
.
BakeNodes
();
SceneView
.
RepaintAll
();
}
if
(
GUILayout
.
Button
(
"Clear"
))
{
myTarget
.
ClearNodes
();
SceneView
.
RepaintAll
();
}
}
}
Assets/Pathfinding.unity
View file @
8cfc3dea
...
...
@@ -221,7 +221,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
38041422
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-4.76
,
y
:
-4.97
,
z
:
-41.328003
}
m_LocalPosition
:
{
x
:
-4.76
,
y
:
-4.97
,
z
:
0
}
m_LocalScale
:
{
x
:
10
,
y
:
5
,
z
:
0
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
...
...
@@ -259,7 +259,7 @@ MonoBehaviour:
bounds
:
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_Extent
:
{
x
:
10
,
y
:
10
,
z
:
0
}
pointInterval
:
0.
907
pointInterval
:
0.
324
blockMask
:
serializedVersion
:
2
m_Bits
:
256
...
...
@@ -379,7 +379,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
614196138
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
3.74
,
y
:
-1.72
,
z
:
-41.328003
}
m_LocalPosition
:
{
x
:
3.74
,
y
:
-1.72
,
z
:
0
}
m_LocalScale
:
{
x
:
50.72
,
y
:
10
,
z
:
16.9931
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
...
...
@@ -486,7 +486,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1002756477
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-0.032
,
y
:
4.9
,
z
:
-41.328003
}
m_LocalPosition
:
{
x
:
-0.032
,
y
:
4.9
,
z
:
0
}
m_LocalScale
:
{
x
:
50.72
,
y
:
10
,
z
:
16.9931
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
...
...
@@ -593,7 +593,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1036674795
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0.2588191
,
w
:
0.9659258
}
m_LocalPosition
:
{
x
:
-5.48
,
y
:
-0.04
,
z
:
-41.328003
}
m_LocalPosition
:
{
x
:
-5.48
,
y
:
-0.04
,
z
:
0
}
m_LocalScale
:
{
x
:
50.72
,
y
:
10
,
z
:
16.9931
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
...
...
@@ -700,12 +700,135 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1324657432
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0.7071068
,
w
:
0.7071068
}
m_LocalPosition
:
{
x
:
3.33
,
y
:
-6.5
,
z
:
-41.328003
}
m_LocalPosition
:
{
x
:
3.33
,
y
:
-6.5
,
z
:
0
}
m_LocalScale
:
{
x
:
50
,
y
:
5
,
z
:
0
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
6
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
90
}
---
!u!1
&1592952600
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
1592952604
}
-
component
:
{
fileID
:
1592952603
}
-
component
:
{
fileID
:
1592952602
}
-
component
:
{
fileID
:
1592952601
}
m_Layer
:
8
m_Name
:
New Sprite (5)
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!114
&1592952601
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1592952600
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
f4a5a47a8846b8940a9edd3801d55993
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
pathFinder
:
{
fileID
:
178212234
}
destination
:
{
x
:
0
,
y
:
0
,
z
:
0
}
path
:
[]
---
!u!61
&1592952602
BoxCollider2D
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1592952600
}
m_Enabled
:
1
m_Density
:
1
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_UsedByEffector
:
0
m_UsedByComposite
:
0
m_Offset
:
{
x
:
0
,
y
:
0
}
m_SpriteTilingProperty
:
border
:
{
x
:
0.049999997
,
y
:
0.049999997
,
z
:
0.049999997
,
w
:
0.049999997
}
pivot
:
{
x
:
0.5
,
y
:
0.5
}
oldSize
:
{
x
:
0.16
,
y
:
0.16
}
newSize
:
{
x
:
0.16
,
y
:
0.16
}
adaptiveTilingThreshold
:
0.5
drawMode
:
0
adaptiveTiling
:
0
m_AutoTiling
:
0
serializedVersion
:
2
m_Size
:
{
x
:
0.16
,
y
:
0.16
}
m_EdgeRadius
:
0
---
!u!212
&1592952603
SpriteRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1592952600
}
m_Enabled
:
1
m_CastShadows
:
0
m_ReceiveShadows
:
0
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_RenderingLayerMask
:
1
m_RendererPriority
:
0
m_Materials
:
-
{
fileID
:
10754
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
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
:
0
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
m_Sprite
:
{
fileID
:
10911
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_FlipX
:
0
m_FlipY
:
0
m_DrawMode
:
0
m_Size
:
{
x
:
0.16
,
y
:
0.16
}
m_AdaptiveModeThreshold
:
0.5
m_SpriteTileMode
:
0
m_WasSpriteAssigned
:
1
m_MaskInteraction
:
0
m_SpriteSortPoint
:
0
---
!u!4
&1592952604
Transform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1592952600
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-4.76
,
y
:
-2.64
,
z
:
0
}
m_LocalScale
:
{
x
:
2
,
y
:
2
,
z
:
0
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
7
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1627406709
GameObject
:
m_ObjectHideFlags
:
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment