diff --git a/Client/Assets/Photon/FusionAddons/Photon-Fusion-Physics-Addon-2.0.0-RC3-807.unitypackage.meta b/Client/Assets/Photon/FusionAddons/Photon-Fusion-Physics-Addon-2.0.0-RC3-807.unitypackage.meta deleted file mode 100644 index 587fe80d09..0000000000 --- a/Client/Assets/Photon/FusionAddons/Photon-Fusion-Physics-Addon-2.0.0-RC3-807.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8b9ed61988db5114eb0062cbe1959387 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Client/Assets/Photon/FusionAddons/Photon-Fusion-TestSuit-Addon-2.0.0-RC3-807.unitypackage.meta b/Client/Assets/Photon/FusionAddons/Photon-Fusion-TestSuit-Addon-2.0.0-RC3-807.unitypackage.meta deleted file mode 100644 index 960c9c9a5e..0000000000 --- a/Client/Assets/Photon/FusionAddons/Photon-Fusion-TestSuit-Addon-2.0.0-RC3-807.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e8e485ea5fdb85e4a80d554bae0ad087 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Client/Assets/Photon/FusionDemos/Photon-Fusion-Intro-Sample-2.0.0-RC3-807.unitypackage.meta b/Client/Assets/Photon/FusionDemos/Photon-Fusion-Intro-Sample-2.0.0-RC3-807.unitypackage.meta deleted file mode 100644 index 0c478432ff..0000000000 --- a/Client/Assets/Photon/FusionDemos/Photon-Fusion-Intro-Sample-2.0.0-RC3-807.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5a77421e106bc7a4d8a5d79f2e4c1b7e -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Client/Assets/Resources/Prefabs/Cameras/CreatureCamera.prefab b/Client/Assets/Resources/Prefabs/Cameras/CreatureCamera.prefab index 4087f1d89a..a975e8b15c 100644 --- a/Client/Assets/Resources/Prefabs/Cameras/CreatureCamera.prefab +++ b/Client/Assets/Resources/Prefabs/Cameras/CreatureCamera.prefab @@ -67,7 +67,7 @@ Camera: y: 0 width: 1 height: 1 - near clip plane: 0.3 + near clip plane: 0.25 far clip plane: 1000 field of view: 60 orthographic: 0 diff --git a/Client/Assets/Scenes/TestScene/TestSceneTemplate.unity b/Client/Assets/Scenes/TestScene/TestSceneTemplate.unity index fd9f2ae7e8..e62e04ed63 100644 --- a/Client/Assets/Scenes/TestScene/TestSceneTemplate.unity +++ b/Client/Assets/Scenes/TestScene/TestSceneTemplate.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 261.98517, g: 324.57465, b: 429.57983, a: 1} + m_IndirectSpecularColor: {r: 262.31375, g: 325.03055, b: 430.1734, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -180,6 +180,112 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &918264916 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 918264920} + - component: {fileID: 918264919} + - component: {fileID: 918264918} + - component: {fileID: 918264917} + m_Layer: 0 + m_Name: Plane + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &918264917 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 918264916} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 5 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &918264918 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 918264916} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 257 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2} + 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: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &918264919 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 918264916} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &918264920 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 918264916} + serializedVersion: 2 + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1284045660 GameObject: m_ObjectHideFlags: 0 @@ -622,3 +728,4 @@ SceneRoots: - {fileID: 1607530586} - {fileID: 1421730658} - {fileID: 580236018} + - {fileID: 918264920} diff --git a/Client/Assets/Scripts/Contents/AnimController.cs b/Client/Assets/Scripts/Contents/AnimController.cs index a06fec8e34..6482b8e5a5 100644 --- a/Client/Assets/Scripts/Contents/AnimController.cs +++ b/Client/Assets/Scripts/Contents/AnimController.cs @@ -31,6 +31,9 @@ protected virtual void Init() #region Update public void UpdateAnimation() { + if (HasStateAuthority == false) + return; + switch (CreatureState) { case Define.CreatureState.Idle: @@ -39,8 +42,8 @@ public void UpdateAnimation() case Define.CreatureState.Move: PlayMove(); break; - case Define.CreatureState.Use: - PlayUse(); + case Define.CreatureState.Interact: + PlayInteract(); break; case Define.CreatureState.Dead: PlayDead(); @@ -56,6 +59,7 @@ protected void PlayIdle() switch (CreaturePose) { case Define.CreaturePose.Stand: + case Define.CreaturePose.Run: float smoothness = 5f; // 조절 가능한 부드러움 계수 SitDown = Mathf.Lerp(SitDown, 0, Runner.DeltaTime * smoothness); SetFloat("Sit", SitDown); @@ -75,7 +79,7 @@ protected void PlayIdle() { } - + } protected void PlayMove() @@ -109,10 +113,10 @@ protected void PlayMove() { } - + } - protected void PlayUse() + protected void PlayInteract() { // TODO } diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/IInteractable.cs b/Client/Assets/Scripts/Contents/Map/Interactive/IInteractable.cs index c4c194ad2d..d1389d6007 100644 --- a/Client/Assets/Scripts/Contents/Map/Interactive/IInteractable.cs +++ b/Client/Assets/Scripts/Contents/Map/Interactive/IInteractable.cs @@ -1,7 +1,3 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - public interface IInteractable { public void Interact(); diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/Item.meta b/Client/Assets/Scripts/Contents/Map/Interactive/Item.meta new file mode 100644 index 0000000000..109f32bc13 --- /dev/null +++ b/Client/Assets/Scripts/Contents/Map/Interactive/Item.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 10b9b539d89d49ab942d1ee133cdb298 +timeCreated: 1710519183 \ No newline at end of file diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs b/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs new file mode 100644 index 0000000000..fc5e931e12 --- /dev/null +++ b/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs @@ -0,0 +1,9 @@ +using Fusion; + +public class BaseItem : NetworkBehaviour, IInteractable +{ + public void Interact() + { + + } +} diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs.meta new file mode 100644 index 0000000000..2c7f492e51 --- /dev/null +++ b/Client/Assets/Scripts/Contents/Map/Interactive/Item/BaseItem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 49fe08f8bb83467ab0f8accb613f1b7b +timeCreated: 1710518821 \ No newline at end of file diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.meta new file mode 100644 index 0000000000..c3a54828a7 --- /dev/null +++ b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 973dad1522e34f968fbabb971a752470 +timeCreated: 1710519209 \ No newline at end of file diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/ElectricSystem.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricSystem.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/ElectricSystem.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricSystem.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/ElectricSystem.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricSystem.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/ElectricSystem.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricSystem.cs.meta diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/ElectricsystemButton.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricsystemButton.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/ElectricsystemButton.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricsystemButton.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/ElectricsystemButton.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricsystemButton.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/ElectricsystemButton.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/ElectricsystemButton.cs.meta diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/EscapeShip.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/EscapeShip.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/EscapeShip.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/EscapeShip.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/EscapeShip.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/EscapeShip.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/EscapeShip.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/EscapeShip.cs.meta diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/Gate.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/Gate.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/Gate.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/Gate.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/Gate.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/Gate.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/Gate.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/Gate.cs.meta diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/SectorLight.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/SectorLight.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/SectorLight.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/SectorLight.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/SectorLight.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/SectorLight.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/SectorLight.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/SectorLight.cs.meta diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.cs b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/WorkStation.cs similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.cs rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/WorkStation.cs diff --git a/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.cs.meta b/Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/WorkStation.cs.meta similarity index 100% rename from Client/Assets/Scripts/Contents/Map/Interactive/WorkStation.cs.meta rename to Client/Assets/Scripts/Contents/Map/Interactive/WorkStation/WorkStation.cs.meta diff --git a/Client/Assets/Scripts/Controllers/Alien.cs b/Client/Assets/Scripts/Controllers/Alien.cs index d7ac602947..d4a18f9587 100644 --- a/Client/Assets/Scripts/Controllers/Alien.cs +++ b/Client/Assets/Scripts/Controllers/Alien.cs @@ -24,7 +24,7 @@ protected override void HandleInput() { base.HandleInput(); - if (CreatureState == Define.CreatureState.Use) + if (CreatureState == Define.CreatureState.Interact) { // TODO return; diff --git a/Client/Assets/Scripts/Controllers/Creature.cs b/Client/Assets/Scripts/Controllers/Creature.cs index a1f164cdd9..b3782c0aa3 100644 --- a/Client/Assets/Scripts/Controllers/Creature.cs +++ b/Client/Assets/Scripts/Controllers/Creature.cs @@ -4,6 +4,8 @@ public abstract class Creature : NetworkBehaviour { + public const bool IsFirstPersonView = true; + #region Field public CreatureCamera CreatureCamera { get; protected set; } @@ -23,7 +25,6 @@ public abstract class Creature : NetworkBehaviour [Networked] public Define.CreatureState CreatureState { get; set; } [Networked] public Define.CreaturePose CreaturePose { get; set; } - [Networked] public Quaternion CameraQuaternion { get; set; } [Networked] public Vector3 Velocity { get; set; } #endregion @@ -63,13 +64,18 @@ public virtual void SetInfo(int templateID) Managers.ObjectMng.MyCreature = this; - CreatureCamera = Managers.ResourceMng.Instantiate("Cameras/CreatureCamera", gameObject.transform).GetComponent(); - CreatureCamera.enabled = true; - CreatureCamera.Creature = this; + if (IsFirstPersonView) + { - //WatchingCamera = Managers.ResourceMng.Instantiate("Cameras/WatchingCamera", gameObject.transform).GetComponent(); - //WatchingCamera.enabled = true; - //WatchingCamera.Creature = this; + CreatureCamera = Managers.ResourceMng.Instantiate("Cameras/CreatureCamera", gameObject.transform).GetComponent(); + CreatureCamera.SetInfo(this); + } + else + { + WatchingCamera = Managers.ResourceMng.Instantiate("Cameras/WatchingCamera", gameObject.transform).GetComponent(); + WatchingCamera.enabled = true; + WatchingCamera.Creature = this; + } Rpc_SetInfo(templateID); } @@ -96,41 +102,27 @@ public override void FixedUpdateNetwork() HandleInput(); UpdateByState(); AnimController.UpdateAnimation(); - CameraUpdate(); } protected virtual void HandleInput() { - //Quaternion cameraRotationY = Quaternion.Euler(0, WatchingCamera.transform.rotation.eulerAngles.y, 0); - //Velocity = cameraRotationY * new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * CreatureStat.Speed * Runner.DeltaTime; + if (IsFirstPersonView) + { - Quaternion cameraRotationY = Quaternion.Euler(0, CreatureCamera.transform.rotation.eulerAngles.y, 0); - Velocity = cameraRotationY * new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * CreatureStat.Speed * Runner.DeltaTime; + Quaternion cameraRotationY = Quaternion.Euler(0, CreatureCamera.transform.rotation.eulerAngles.y, 0); + Velocity = cameraRotationY * new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * + CreatureStat.Speed * Runner.DeltaTime; + } + else + { + Quaternion cameraRotationY = Quaternion.Euler(0, WatchingCamera.transform.rotation.eulerAngles.y, 0); + Velocity = cameraRotationY * new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * + CreatureStat.Speed * Runner.DeltaTime; + } } #region Update - protected void CameraUpdate() - { - if (HasStateAuthority == false) - return; - - if (CreatureCamera != null) - CreatureCameraUpdate(); - else if (WatchingCamera != null) - WatchingCameraUpdate(); - } - - protected void CreatureCameraUpdate() - { - CameraQuaternion = Quaternion.Euler(0, CreatureCamera.transform.rotation.eulerAngles.y, 0); - } - - protected void WatchingCameraUpdate() - { - CameraQuaternion = Quaternion.Euler(0, WatchingCamera.transform.rotation.eulerAngles.y, 0); - } - protected void UpdateByState() { if (HasStateAuthority == false) @@ -144,7 +136,7 @@ protected void UpdateByState() case Define.CreatureState.Move: UpdateMove(); break; - case Define.CreatureState.Use: + case Define.CreatureState.Interact: UpdateUse(); break; case Define.CreatureState.Dead: diff --git a/Client/Assets/Scripts/Controllers/CreatureCamera.cs b/Client/Assets/Scripts/Controllers/CreatureCamera.cs index a549752810..892aeb03aa 100644 --- a/Client/Assets/Scripts/Controllers/CreatureCamera.cs +++ b/Client/Assets/Scripts/Controllers/CreatureCamera.cs @@ -5,9 +5,10 @@ public class CreatureCamera : MonoBehaviour { - //1인칭 카메라 public Creature Creature { get; set; } + public Camera Camera { get; protected set; } + public float MouseSensitivity { get; protected set; } public float XRotation { get; protected set; } // 카메라의 상하 회전을 위한 변수 public float CurrentAngle { get; protected set; } @@ -19,10 +20,21 @@ private void Awake() protected void Init() { + Camera = GetComponent(); + CurrentAngle = 0; MouseSensitivity = 1.5f; XRotation = 0; } + + public void SetInfo(Creature creature) + { + enabled = true; + Creature = creature; + + transform.position = Util.FindChild(Creature.gameObject, "head").transform.position + new Vector3(0f, 0.2f, 0.2f); + } + private void LateUpdate() { if (Creature != null) @@ -32,6 +44,7 @@ private void LateUpdate() } #region past + void UpdateCameraAngle() { // 마우스 입력을 받아와 회전 각도 계산 @@ -41,15 +54,11 @@ void UpdateCameraAngle() XRotation -= mouseY * MouseSensitivity; // 상하 회전 값 계산 CurrentAngle = Mathf.Repeat(CurrentAngle, 360f); // 각도를 0부터 360도 사이로 유지 - XRotation = Mathf.Clamp(XRotation, -90f, 90f); // 상하 회전 범위를 -90도에서 90도로 제한 - - Vector3 cameraPosition = new Vector3(0, 1.7f, 0.5f); + XRotation = Mathf.Clamp(XRotation, -60f, 60f); // 상하 회전 범위를 -90도에서 90도로 제한 - transform.position = Creature.transform.position + cameraPosition; // 플레이어를 중심으로 하는 원형 궤도에 따라 카메라 이동 - Quaternion rotation = Quaternion.Euler(XRotation, CurrentAngle, 0); transform.rotation = rotation; // 카메라 회전 적용 - } + #endregion } diff --git a/Client/Assets/Scripts/Controllers/Crew.cs b/Client/Assets/Scripts/Controllers/Crew.cs index 67ae1ee471..1c8777eefa 100644 --- a/Client/Assets/Scripts/Controllers/Crew.cs +++ b/Client/Assets/Scripts/Controllers/Crew.cs @@ -9,8 +9,6 @@ public class Crew : Creature public CrewData CrewData => CreatureData as CrewData; public CrewStat CrewStat => (CrewStat)CreatureStat; - [Networked] public NetworkBool _IsDamaged { get => default; set { } } - #endregion public override void Spawned() { @@ -25,66 +23,49 @@ public override void SetInfo(int templateID) base.SetInfo(templateID); CrewStat.SetStat(CrewData); - } - public override void FixedUpdateNetwork() + protected override void HandleInput() { - base.FixedUpdateNetwork(); + base.HandleInput(); - } + if (CreatureState == Define.CreatureState.Dead) + return; - #region Input + if (Input.GetKeyDown(KeyCode.F)) + { + if (CreatureState == Define.CreatureState.Interact) + CreatureState = Define.CreatureState.Idle; + else + InterAct(); - protected override void HandleInput() - { - base.HandleInput(); + return; + } - if (CreatureState == Define.CreatureState.Use) + if (Input.GetKeyDown(KeyCode.C)) { - // TODO + if (CreaturePose != Define.CreaturePose.Sit) + CreaturePose = Define.CreaturePose.Sit; + else + CreaturePose = Define.CreaturePose.Stand; + return; } if (Velocity == Vector3.zero) - { CreatureState = Define.CreatureState.Idle; - //가만히 서 있는 상태일 때에도 앉기를 하기 위해 return 제거 - } else { - CreatureState = Define.CreatureState.Move; //else를 통해 키 입력이 있는 경우 move로 상태변환 - } + CreatureState = Define.CreatureState.Move; - if (Input.GetKeyDown(KeyCode.LeftShift)) //앉아 있는 상태에서는 달리기가 적용되지 않게 적용 - { - if (CreaturePose != Define.CreaturePose.Sit) - { + if (Input.GetKey(KeyCode.LeftShift)) CreaturePose = Define.CreaturePose.Run; - } - } - if (Input.GetKeyUp(KeyCode.LeftShift)) //앉아 있는 상태에서 shift를 눌렀다 떼어도 자세 변화가 없게 하기 위해 - { - if (CreaturePose != Define.CreaturePose.Sit) - { - CreaturePose = Define.CreaturePose.Stand; - } - } - if (Input.GetKeyDown(KeyCode.C)) //c키를 눌렸을 경우 현재 앉아 있는지, 서있는 상태인지에 따라 반대되는 상태로 변환되도록 설정 - { - if (CreaturePose != Define.CreaturePose.Sit) - { - CreaturePose = Define.CreaturePose.Sit; - } else - { - CreaturePose = Define.CreaturePose.Stand; - } + if (CreaturePose == Define.CreaturePose.Run) + CreaturePose = Define.CreaturePose.Stand; } } - #endregion - #region Update protected override void UpdateIdle() @@ -98,11 +79,14 @@ protected override void UpdateIdle() // TODO break; case Define.CreaturePose.Run: - Debug.Log("No Idle_Run"); + // TODO break; } - //1인칭 카메라 회전에 따라 오브젝트도 회전 - KCC.SetLookRotation(0, CreatureCamera.transform.rotation.eulerAngles.y); + + if (IsFirstPersonView) + { + KCC.SetLookRotation(0, CreatureCamera.transform.rotation.eulerAngles.y); + } } protected override void UpdateMove() @@ -120,17 +104,20 @@ protected override void UpdateMove() break; } - KCC.Move(Velocity, 0f); - - //3인칭 오브젝트 회전 - //if (Velocity != Vector3.zero) - //{ - // Quaternion newRotation = Quaternion.LookRotation(Velocity); - // KCC.SetLookRotation(newRotation); - //} + if (IsFirstPersonView) + { + KCC.SetLookRotation(0, CreatureCamera.transform.rotation.eulerAngles.y); + } + else + { + if (Velocity != Vector3.zero) + { + Quaternion newRotation = Quaternion.LookRotation(Velocity); + KCC.SetLookRotation(newRotation); + } + } - //1인칭 카메라가 회전할 때만 오브젝트 회전 - KCC.SetLookRotation(0, CreatureCamera.transform.rotation.eulerAngles.y); + KCC.Move(Velocity, 0f); } protected override void UpdateUse() @@ -147,6 +134,26 @@ protected override void UpdateDead() #region Event + protected void InterAct() + { + Ray ray = CreatureCamera.GetComponent().ScreenPointToRay(Input.mousePosition); + + if (Physics.Raycast(ray, out RaycastHit rayHit, maxDistance: 3f, layerMask: LayerMask.GetMask("Interact"))) + { + CreatureState = Define.CreatureState.Interact; + + IInteractable interactable = rayHit.transform.gameObject.GetComponent(); + interactable.Interact(); + + Debug.DrawLine(ray.origin, rayHit.point, Color.red, 1f); // TODO - Test Code + } + else + { + Debug.Log("Failed to InterAct"); + Debug.DrawRay(ray.origin, ray.direction * 3f, Color.red, 1f); // TODO - Test Code + } + } + public void OnDamaged(int damage) { CrewStat.OnDamage(damage); diff --git a/Client/Assets/Scripts/Controllers/WatchingCamera.cs b/Client/Assets/Scripts/Controllers/WatchingCamera.cs index 8bb299b639..ef6ebcda1d 100644 --- a/Client/Assets/Scripts/Controllers/WatchingCamera.cs +++ b/Client/Assets/Scripts/Controllers/WatchingCamera.cs @@ -1,16 +1,19 @@ -using Fusion; +using Fusion; using UnityEngine; using UnityEngine.Serialization; public class WatchingCamera : MonoBehaviour { - //3인칭 카메라 public Creature Creature { get; set; } + public Camera Camera { get; protected set; } + public float MouseSensitivity { get; protected set; } public float XRotation { get; protected set; } // 카메라의 상하 회전을 위한 변수 public float CurrentAngle { get; protected set; } + float _distance = 2f; // 원의 반지름 설정 (조절 가능) + private void Awake() { Init(); @@ -18,10 +21,21 @@ private void Awake() protected void Init() { + Camera = GetComponent(); + CurrentAngle = 180f; MouseSensitivity = 1.5f; XRotation = 0f; } + + public void SetInfo(Creature creature) + { + enabled = true; + Creature = creature; + + transform.position = Util.FindChild(Creature.gameObject, "head").transform.position; + } + private void LateUpdate() { if (Creature != null) @@ -42,8 +56,7 @@ void UpdateCameraAngle() XRotation = Mathf.Clamp(XRotation, -90f, 90f); // 상하 회전 범위를 -90도에서 90도로 제한 float radianAngle = Mathf.Deg2Rad * CurrentAngle; // 원형 궤도 상의 위치 계산 - float distance = 2f; // 원의 반지름 설정 (조절 가능) - Vector3 cameraPosition = new Vector3(Mathf.Sin(radianAngle) * distance, 1.7f, Mathf.Cos(radianAngle) * distance); + Vector3 cameraPosition = new Vector3(Mathf.Sin(radianAngle) * _distance, 1.7f, Mathf.Cos(radianAngle) * _distance); transform.position = Creature.transform.position + cameraPosition; // 플레이어를 중심으로 하는 원형 궤도에 따라 카메라 이동 Vector3 lookDirection = (Creature.transform.position + Vector3.up * 1.7f) - transform.position; // 플레이어를 바라보는 방향 벡터 설정 diff --git a/Client/Assets/Scripts/Utils/Define.cs b/Client/Assets/Scripts/Utils/Define.cs index 0691f2fe56..f4a8752ee9 100644 --- a/Client/Assets/Scripts/Utils/Define.cs +++ b/Client/Assets/Scripts/Utils/Define.cs @@ -60,7 +60,7 @@ public enum CreatureState { Idle, Move, - Use, + Interact, Dead, } diff --git a/Client/ProjectSettings/TagManager.asset b/Client/ProjectSettings/TagManager.asset index 91da68c943..20efa9ed16 100644 --- a/Client/ProjectSettings/TagManager.asset +++ b/Client/ProjectSettings/TagManager.asset @@ -12,9 +12,9 @@ TagManager: - - Water - UI - - - - - - + - Crew + - Alien + - Interact - Ground - Block -