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
15bcb18e
Commit
15bcb18e
authored
May 12, 2019
by
18손재민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
카메라 회전 일단 구현
parent
dba4f6af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
Data.meta
Assets/Data.meta
+8
-0
SampleScene.unity
Assets/Scenes/SampleScene.unity
+6
-0
CameraController.cs
Assets/Scripts/CameraController.cs
+27
-0
No files found.
Assets/Data.meta
0 → 100644
View file @
15bcb18e
fileFormatVersion: 2
guid: f6226b2548447a54486acfc694a44e4d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scenes/SampleScene.unity
View file @
15bcb18e
...
...
@@ -276,6 +276,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
c7d507df55441f7438f6f059e9d2587c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
dragSpeed
:
10
---
!u!114
&2102809461
stripped
MonoBehaviour
:
m_CorrespondingSourceObject
:
{
fileID
:
7277015661519863741
,
guid
:
20dee07e28273f049a9093ae4453912f
,
...
...
@@ -490,6 +491,11 @@ PrefabInstance:
propertyPath
:
m_LocalEulerAnglesHint.z
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
1444571407667829093
,
guid
:
0b18400fb62a12d4e9cb5fbb8ecbb53f
,
type
:
3
}
propertyPath
:
m_LocalPosition.z
value
:
0
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
0b18400fb62a12d4e9cb5fbb8ecbb53f
,
type
:
3
}
---
!u!1001
&5089720519379341084
...
...
Assets/Scripts/CameraController.cs
View file @
15bcb18e
...
...
@@ -4,6 +4,8 @@ using UnityEngine;
public
class
CameraController
:
MonoBehaviour
{
Vector3
dragOrigin
;
public
float
dragSpeed
;
void
CameraMove
()
{
...
...
@@ -12,15 +14,40 @@ public class CameraController : MonoBehaviour
transform
.
position
+=
new
Vector3
(
verticalInput
+
horizontalInput
,
0
,
verticalInput
-
horizontalInput
);
}
void
CameraDrag
()
{
if
(
Input
.
GetMouseButtonDown
(
1
))
{
dragOrigin
=
Input
.
mousePosition
;
return
;
}
if
(!
Input
.
GetMouseButton
(
1
))
return
;
float
deg
=
Mathf
.
Atan2
(
transform
.
position
.
z
,
transform
.
position
.
x
);
float
dis
=
Vector3
.
Distance
(
Vector3
.
zero
,
transform
.
position
-
new
Vector3
(
0
,
transform
.
position
.
y
,
0
));
float
dif
=
Camera
.
main
.
ScreenToViewportPoint
(
Input
.
mousePosition
-
dragOrigin
).
x
*
dragSpeed
;
transform
.
position
=
new
Vector3
(
Mathf
.
Cos
(
deg
+
dif
)
*
dis
,
transform
.
position
.
y
,
Mathf
.
Sin
(
deg
+
dif
)
*
dis
);
transform
.
LookAt
(
new
Vector3
(
0
,
0
,
0
));
dragOrigin
=
Input
.
mousePosition
;
}
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
CameraMove
();
CameraDrag
();
}
}
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