Commit abe8e81c authored by 15박보승's avatar 15박보승

플레이어 컨트롤로 초안 완성/카메라 시점 개선

parent cf048ec3
......@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
......@@ -151,7 +151,7 @@ Transform:
m_GameObject: {fileID: 48712142}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 10.6, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
......@@ -248,7 +248,7 @@ LineRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 0}
- {fileID: 10306, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......@@ -274,7 +274,7 @@ LineRenderer:
- {x: 0, y: 0, z: 0}
m_Parameters:
serializedVersion: 3
widthMultiplier: 1
widthMultiplier: 0.1
widthCurve:
serializedVersion: 2
m_Curve:
......@@ -292,8 +292,8 @@ LineRenderer:
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key0: {r: 1, g: 0, b: 0, a: 1}
key1: {r: 1, g: 0, b: 0, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
......@@ -560,6 +560,81 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &330379322
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 330379323}
- component: {fileID: 330379325}
- component: {fileID: 330379324}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &330379323
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330379322}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 413298776}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 5, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &330379324
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330379322}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &330379325
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330379322}
m_CullTransparentMesh: 0
--- !u!1 &398288500
GameObject:
m_ObjectHideFlags: 0
......@@ -686,6 +761,105 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 112
m_CollisionDetection: 0
--- !u!1 &413298772
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 413298776}
- component: {fileID: 413298775}
- component: {fileID: 413298774}
- component: {fileID: 413298773}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &413298773
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 413298772}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &413298774
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 413298772}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &413298775
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 413298772}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &413298776
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 413298772}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 330379323}
m_Father: {fileID: 0}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &519663054
GameObject:
m_ObjectHideFlags: 0
......@@ -995,6 +1169,36 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 126
m_CollisionDetection: 0
--- !u!1 &887314838
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 887314839}
m_Layer: 8
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &887314839
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 887314838}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1171556388}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
......@@ -1046,7 +1250,7 @@ Camera:
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
far clip plane: 10000
field of view: 60
orthographic: 0
orthographic size: 5
......@@ -1092,7 +1296,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
target: {fileID: 1171556388}
offset: {x: 0, y: 3, z: 0}
offset: {x: 0, y: 1.5, z: 0}
distance: 5
--- !u!1 &1064531518
GameObject:
......@@ -1235,7 +1439,7 @@ Rigidbody:
m_GameObject: {fileID: 1171556382}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_Drag: 0.1
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
......@@ -1329,9 +1533,10 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1171556382}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalPosition: {x: 0, y: -4.05, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Children:
- {fileID: 887314839}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -1349,6 +1554,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
distance: 10
hook: {fileID: 48712149}
groundChecker: {fileID: 887314839}
groundMask:
serializedVersion: 2
m_Bits: 1
--- !u!136 &1171556390
CapsuleCollider:
m_ObjectHideFlags: 0
......@@ -1472,6 +1681,72 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1439349407
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1439349410}
- component: {fileID: 1439349409}
- component: {fileID: 1439349408}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1439349408
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1439349407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &1439349409
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1439349407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1439349410
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1439349407}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1838386149
GameObject:
m_ObjectHideFlags: 0
......
......@@ -25,14 +25,14 @@ public class CameraController : MonoBehaviour
private void Update()
{
currentX += Input.GetAxis("Mouse X");
currentY = Mathf.Clamp(currentY - Input.GetAxis("Mouse Y"), -60, 60);
currentY = Mathf.Clamp(currentY - Input.GetAxis("Mouse Y"), -89, 89);
}
private void LateUpdate()
{
Vector3 dir = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
transform.position = offset + target.position + rotation * dir;
transform.position = /*offset +*/ target.position + rotation * dir;
target.rotation = Quaternion.Euler(0, currentX, 0);
transform.LookAt(target.position + offset);
}
......
......@@ -24,8 +24,9 @@ public class DistanceJoint3D : MonoBehaviour
{
if (distance > 0)
{
distance = Mathf.Max(0, distance - 50 * Time.deltaTime);
}
distance = Mathf.Max(0, distance - 100 * Time.deltaTime);
//distance = Mathf.Lerp(distance, 0, 0.8f);
}
}
private void FixedUpdate()
{
......
......@@ -12,7 +12,12 @@ public class HookBehaviour : MonoBehaviour
[SerializeField]
private Rigidbody rb;
private void Awake()
private void OnDrawGizmos()
{
}
private void Awake()
{
rb = GetComponent<Rigidbody>();
gameObject.SetActive(false);
......@@ -26,7 +31,6 @@ public class HookBehaviour : MonoBehaviour
private void OnCollisionEnter(Collision collision)
{
Debug.Log(collision.gameObject);
rb.velocity = Vector3.zero;
rb.isKinematic = true;
player.GetComponent<PlayerController>().ActiveWire();
......
......@@ -6,7 +6,7 @@ using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float distance = 10.0f;
//private CharacterController cc;
float velocityY = 0.0f;
const float gravity = 9.8f;
......@@ -14,22 +14,44 @@ public class PlayerController : MonoBehaviour
public HookBehaviour hook;
private Rigidbody rb;
private DistanceJoint3D joint;
private CapsuleCollider col;
private DistanceJoint3D joint;
private bool isWired;
[SerializeField]
private Transform groundChecker;
[SerializeField]
private LayerMask groundMask;
private bool IsGrounded
{
get {
return Physics.OverlapSphere(groundChecker.position, 0.01f, groundMask).Length > 0;
}
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Gizmos.DrawLine(transform.position, (transform.position - Camera.main.transform.position) * 10);
}
Gizmos.color = Color.red;
Gizmos.DrawLine(transform.position, Camera.main.transform.forward.normalized * 200);
if (!IsGrounded)
Gizmos.color = Color.green;
Gizmos.DrawSphere(groundChecker.position, 0.1f);
}
#endif
private void Start()
{
//cc = GetComponent<CharacterController>();
Cursor.lockState = CursorLockMode.Locked;
joint = GetComponent<DistanceJoint3D>();
rb = GetComponent<Rigidbody>();
col = GetComponent<CapsuleCollider>();
//col.enabled = !IsGrounded;
//cc.enabled = IsGrounded;
}
private void Update()
{
......@@ -45,22 +67,18 @@ public class PlayerController : MonoBehaviour
else
ReturnHook();
}
if (!isWired)
{
/*
if (Input.GetButtonDown("Jump") && cc.isGrounded)
velocityY = 5.0f;
if (!cc.isGrounded)
velocityY -= gravity * Time.deltaTime;
cc.Move(horizontal * transform.right + vertical * transform.forward + new Vector3(0, velocityY, 0) * Time.deltaTime);
*/
}
if (IsGrounded)
{
rb.velocity = (horizontal * transform.right + vertical * transform.forward).normalized * 10.0f;
if (Input.GetButtonDown("Jump"))
rb.velocity += new Vector3(0, 5 -rb.velocity.y, 0);
}
else
{
rb.AddForce(horizontal * transform.right + vertical * transform.forward * 10.0f);
}
}
}
private void LateUpdate()
{
......@@ -72,7 +90,7 @@ public class PlayerController : MonoBehaviour
joint.enabled = false;
hook.gameObject.SetActive(true);
hook.transform.position = transform.position;
hook.EnableHook((transform.position - Camera.main.transform.position).normalized * 200);
hook.EnableHook(Camera.main.transform.forward.normalized * 200);
}
private void ReturnHook()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment