Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
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
Flatland
curvedflats
Commits
6ffdbed0
Commit
6ffdbed0
authored
5 years ago
by
16이진형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto move multi path
parent
2588e633
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
FlatlandMovement.cs
Assets/Scripts/FlatlandMovement.cs
+14
-15
No files found.
Assets/Scripts/FlatlandMovement.cs
View file @
6ffdbed0
...
...
@@ -32,9 +32,9 @@ public class FlatlandMovement : MonoBehaviour
Vector3
nowDest
;
/// <summary>
/// 앞으로 남은
경로
들.
/// 앞으로 남은
목적지
들.
/// </summary>
List
<
Vector3
>
path
s
=
new
List
<
Vector3
>();
List
<
Vector3
>
dest
s
=
new
List
<
Vector3
>();
/// <summary>
/// 앞으로 남은 목적지 속력
/// </summary>
...
...
@@ -52,11 +52,11 @@ public class FlatlandMovement : MonoBehaviour
Debug
.
Log
(
"dest"
+
nowDest
);
Debug
.
Log
(
"position"
+
transform
.
position
);
if
(
path
s
.
Count
>=
1
)
if
(
dest
s
.
Count
>=
1
)
{
// 다음 목적지가 있을떄.
MoveTo
(
path
s
[
0
],
pathVelocitys
[
0
]);
//이동한다.
path
s
.
RemoveAt
(
0
);
MoveTo
(
dest
s
[
0
],
pathVelocitys
[
0
]);
//이동한다.
dest
s
.
RemoveAt
(
0
);
pathVelocitys
.
RemoveAt
(
0
);
}
...
...
@@ -114,23 +114,22 @@ public class FlatlandMovement : MonoBehaviour
if
(
path
.
Count
>=
2
)
{
paths
=
new
List
<
Vector3
>();
dests
=
new
List
<
Vector3
>();
//xy 공간 -> xz 공간
foreach
(
var
a
in
path
)
{
paths
.
Add
(
new
Vector3
(
a
.
x
,
0
,
a
.
y
));
dests
.
Add
(
new
Vector3
(
transform
.
position
.
x
+
a
.
x
,
0
,
transform
.
position
.
z
+
a
.
y
));
}
pathVelocitys
=
new
List
<
float
>(
v
);
//더미 제거
path
s
.
RemoveAt
(
0
);
dest
s
.
RemoveAt
(
0
);
pathVelocitys
.
RemoveAt
(
0
);
}
MoveTo
(
path
s
[
0
],
pathVelocitys
[
0
]);
MoveTo
(
dest
s
[
0
],
pathVelocitys
[
0
]);
path
s
.
RemoveAt
(
0
);
dest
s
.
RemoveAt
(
0
);
pathVelocitys
.
RemoveAt
(
0
);
return
true
;
...
...
@@ -140,22 +139,22 @@ public class FlatlandMovement : MonoBehaviour
/// </summary>
/// <param name="path">목적지 x z 가 공간</param>
/// <param name="v">속력</param>
private
bool
MoveTo
(
Vector3
path
,
float
v
)
private
bool
MoveTo
(
Vector3
dest
,
float
v
)
{
Debug
.
Log
(
"bb"
);
Debug
.
Log
(
path
);
Debug
.
Log
(
dest
);
if
(
v
<
0.0001f
)
{
//v가 0일때.
return
false
;
}
//속도와 목적지 설정.
Vector3
tmp
=
path
;
Vector3
tmp
=
dest
-
transform
.
position
;
Debug
.
Log
(
"move vector: "
+
tmp
);
tmp
.
y
=
0
;
this
.
v
=
tmp
.
normalized
*
v
*
(
float
)
Constants
.
c
;
Debug
.
Log
(
"v : "
+
this
.
v
);
this
.
nowDest
=
path
+
new
Vector3
(
transform
.
position
.
x
,
0
,
transform
.
position
.
z
)
;
this
.
nowDest
=
dest
;
isAutoMove
=
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
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