Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
man-in-the-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
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
MIM
man-in-the-mirror
Commits
50404896
Commit
50404896
authored
Jul 15, 2019
by
18손재민
Committed by
15박보승
Jul 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
카메라 회전 및 이동 방식 수정, 현재 이동과 회전이 동시에 됨 나중에 수정할 것
parent
c60bf36c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
5 deletions
+43
-5
CameraController.cs
Assets/Scripts/CameraController.cs
+38
-5
Map.cs
Assets/Scripts/Map/Map.cs
+5
-0
No files found.
Assets/Scripts/CameraController.cs
View file @
50404896
...
@@ -5,6 +5,7 @@ using UnityEngine;
...
@@ -5,6 +5,7 @@ using UnityEngine;
public
class
CameraController
:
MonoBehaviour
public
class
CameraController
:
MonoBehaviour
{
{
Vector3
dragOrigin
;
Vector3
dragOrigin
;
Vector3
moveOrigin
;
public
float
dragSpeed
;
public
float
dragSpeed
;
Vector3
previousPos
;
Vector3
previousPos
;
Vector3
previousAngle
;
Vector3
previousAngle
;
...
@@ -14,16 +15,35 @@ public class CameraController : MonoBehaviour
...
@@ -14,16 +15,35 @@ public class CameraController : MonoBehaviour
float
rotationY
=
0
;
float
rotationY
=
0
;
float
sensitivity
=
30
;
float
sensitivity
=
30
;
[
SerializeField
]
Vector3
centerPos
=
new
Vector3
(
0
,
0
,
0
);
Vector3
centerPos
=
new
Vector3
(
0
,
0
,
0
);
Vector3
distance
=
new
Vector3
(
0
,
0
,
0
);
/// <summary>
/// <summary>
/// Move camera.
/// Move camera.
/// </summary>
/// </summary>
void
CameraMove
()
void
CameraMove
()
{
{
float
horizontalInput
=
Input
.
GetAxis
(
"Horizontal"
);
if
(
Input
.
GetMouseButtonDown
(
2
))
float
verticalInput
=
Input
.
GetAxis
(
"Vertical"
);
{
transform
.
position
+=
new
Vector3
(
verticalInput
+
horizontalInput
,
0
,
verticalInput
-
horizontalInput
);
moveOrigin
=
Input
.
mousePosition
;
return
;
}
if
(!
Input
.
GetMouseButton
(
2
))
{
Vector3
tempVec
=
centerPos
;
centerPos
=
new
Vector3
(
Mathf
.
Clamp
(
Mathf
.
Round
(
centerPos
.
x
*
2
)
/
2
,
MapManager
.
inst
.
currentMap
.
minBorder
.
x
,
MapManager
.
inst
.
currentMap
.
maxBorder
.
x
),
0
,
Mathf
.
Clamp
(
Mathf
.
Round
(
centerPos
.
z
*
2
)
/
2
,
MapManager
.
inst
.
currentMap
.
minBorder
.
y
,
MapManager
.
inst
.
currentMap
.
maxBorder
.
y
));
transform
.
Translate
(
centerPos
-
tempVec
,
Space
.
World
);
return
;
}
float
previousY
=
transform
.
position
.
y
;
Vector3
centerDiff
=
transform
.
position
;
Vector3
pos
=
Camera
.
main
.
ScreenToViewportPoint
(
Input
.
mousePosition
-
moveOrigin
);
moveOrigin
=
Input
.
mousePosition
;
transform
.
Translate
(
new
Vector3
(
pos
.
x
*
-
8
,
pos
.
y
*
-
8
,
0
),
Space
.
Self
);
transform
.
position
=
new
Vector3
(
transform
.
position
.
x
,
previousY
,
transform
.
position
.
z
);
centerPos
+=
transform
.
position
-
centerDiff
;
centerPos
.
y
=
0
;
}
}
/// <summary>
/// <summary>
...
@@ -127,6 +147,7 @@ public class CameraController : MonoBehaviour
...
@@ -127,6 +147,7 @@ public class CameraController : MonoBehaviour
{
{
Camera
.
main
.
fieldOfView
=
mapFov
;
Camera
.
main
.
fieldOfView
=
mapFov
;
transform
.
eulerAngles
=
new
Vector3
(
30
,
transform
.
eulerAngles
.
y
,
transform
.
eulerAngles
.
z
);
transform
.
eulerAngles
=
new
Vector3
(
30
,
transform
.
eulerAngles
.
y
,
transform
.
eulerAngles
.
z
);
distance
=
transform
.
position
-
centerPos
;
}
}
// Update is called once per frame
// Update is called once per frame
...
@@ -136,7 +157,19 @@ public class CameraController : MonoBehaviour
...
@@ -136,7 +157,19 @@ public class CameraController : MonoBehaviour
{
{
if
(!
PlayerController
.
inst
.
isPlayerShooting
)
if
(!
PlayerController
.
inst
.
isPlayerShooting
)
{
{
//CameraMove();
CameraMove
();
CameraDrag
();
CameraDrag
();
}
}
else
else
...
...
Assets/Scripts/Map/Map.cs
View file @
50404896
...
@@ -7,6 +7,7 @@ public class Map : MonoBehaviour
...
@@ -7,6 +7,7 @@ public class Map : MonoBehaviour
{
{
[
Header
(
"Map Data"
)]
[
Header
(
"Map Data"
)]
public
int
maxMapSize
;
public
int
maxMapSize
;
public
Vector2Int
maxBorder
,
minBorder
;
public
Dictionary
<
Vector2Int
,
Floor
>
floorGrid
;
public
Dictionary
<
Vector2Int
,
Floor
>
floorGrid
;
public
Dictionary
<
Vector2
,
Wall
>
wallGrid
;
public
Dictionary
<
Vector2
,
Wall
>
wallGrid
;
public
Dictionary
<
Vector2Int
,
IObject
>
objectGrid
;
public
Dictionary
<
Vector2Int
,
IObject
>
objectGrid
;
...
@@ -65,6 +66,10 @@ public class Map : MonoBehaviour
...
@@ -65,6 +66,10 @@ public class Map : MonoBehaviour
floorGrid
.
Add
(
pos
,
Instantiate
(
MapManager
.
inst
.
floor
,
new
Vector3
(
pos
.
x
,
0
,
pos
.
y
),
Quaternion
.
identity
,
floors
.
transform
).
GetComponent
<
Floor
>());
floorGrid
.
Add
(
pos
,
Instantiate
(
MapManager
.
inst
.
floor
,
new
Vector3
(
pos
.
x
,
0
,
pos
.
y
),
Quaternion
.
identity
,
floors
.
transform
).
GetComponent
<
Floor
>());
floorGrid
[
pos
].
mapPos
=
pos
;
floorGrid
[
pos
].
mapPos
=
pos
;
floorGrid
[
pos
].
isGoalFloor
=
isGoal
;
floorGrid
[
pos
].
isGoalFloor
=
isGoal
;
if
(
pos
.
x
>
maxBorder
.
x
)
maxBorder
.
x
=
pos
.
x
;
else
if
(
pos
.
x
<
minBorder
.
x
)
minBorder
.
x
=
pos
.
x
;
if
(
pos
.
y
>
maxBorder
.
y
)
maxBorder
.
y
=
pos
.
y
;
else
if
(
pos
.
y
<
minBorder
.
y
)
minBorder
.
y
=
pos
.
y
;
if
(
GameManager
.
aFloor
>=
0
&&
isGoal
)
if
(
GameManager
.
aFloor
>=
0
&&
isGoal
)
clearConditions
[
GameManager
.
aFloor
].
IsDone
(
0
,
1
);
clearConditions
[
GameManager
.
aFloor
].
IsDone
(
0
,
1
);
StartCoroutine
(
MapManager
.
inst
.
Rebaker
());
StartCoroutine
(
MapManager
.
inst
.
Rebaker
());
...
...
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