Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 1인칭 카메라 위치 조정 & Crew클래스의 IInteractable과 상호작용 구현 & Crew 클래스의 HandleInput 수정 #5

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
109 changes: 108 additions & 1 deletion Client/Assets/Scenes/TestScene/TestSceneTemplate.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -622,3 +728,4 @@ SceneRoots:
- {fileID: 1607530586}
- {fileID: 1421730658}
- {fileID: 580236018}
- {fileID: 918264920}
14 changes: 9 additions & 5 deletions Client/Assets/Scripts/Contents/AnimController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ protected virtual void Init()
#region Update
public void UpdateAnimation()
{
if (HasStateAuthority == false)
return;

switch (CreatureState)
{
case Define.CreatureState.Idle:
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -75,7 +79,7 @@ protected void PlayIdle()
{

}

}

protected void PlayMove()
Expand Down Expand Up @@ -109,10 +113,10 @@ protected void PlayMove()
{

}

}

protected void PlayUse()
protected void PlayInteract()
{
// TODO
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public interface IInteractable
{
public void Interact();
Expand Down
3 changes: 3 additions & 0 deletions Client/Assets/Scripts/Contents/Map/Interactive/Item.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Fusion;

public class BaseItem : NetworkBehaviour, IInteractable
{
public void Interact()
{

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Client/Assets/Scripts/Controllers/Alien.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override void HandleInput()
{
base.HandleInput();

if (CreatureState == Define.CreatureState.Use)
if (CreatureState == Define.CreatureState.Interact)
{
// TODO
return;
Expand Down
60 changes: 26 additions & 34 deletions Client/Assets/Scripts/Controllers/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public abstract class Creature : NetworkBehaviour
{
public const bool IsFirstPersonView = true;

#region Field

public CreatureCamera CreatureCamera { get; protected set; }
Expand All @@ -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
Expand Down Expand Up @@ -63,13 +64,18 @@ public virtual void SetInfo(int templateID)

Managers.ObjectMng.MyCreature = this;

CreatureCamera = Managers.ResourceMng.Instantiate("Cameras/CreatureCamera", gameObject.transform).GetComponent<CreatureCamera>();
CreatureCamera.enabled = true;
CreatureCamera.Creature = this;
if (IsFirstPersonView)
{

//WatchingCamera = Managers.ResourceMng.Instantiate("Cameras/WatchingCamera", gameObject.transform).GetComponent<WatchingCamera>();
//WatchingCamera.enabled = true;
//WatchingCamera.Creature = this;
CreatureCamera = Managers.ResourceMng.Instantiate("Cameras/CreatureCamera", gameObject.transform).GetComponent<CreatureCamera>();
CreatureCamera.SetInfo(this);
}
else
{
WatchingCamera = Managers.ResourceMng.Instantiate("Cameras/WatchingCamera", gameObject.transform).GetComponent<WatchingCamera>();
WatchingCamera.enabled = true;
WatchingCamera.Creature = this;
}

Rpc_SetInfo(templateID);
}
Expand All @@ -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)
Expand All @@ -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:
Expand Down
Loading