캐릭터 이동 및 애니메이션(이동, 공격) 구현
This commit is contained in:
@@ -5776,89 +5776,6 @@ Transform:
|
|||||||
- {fileID: 681101987}
|
- {fileID: 681101987}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &335091082 stripped
|
|
||||||
GameObject:
|
|
||||||
m_CorrespondingSourceObject: {fileID: 103380811750077614, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 598913983}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
--- !u!50 &335091083
|
|
||||||
Rigidbody2D:
|
|
||||||
serializedVersion: 5
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 335091082}
|
|
||||||
m_BodyType: 0
|
|
||||||
m_Simulated: 1
|
|
||||||
m_UseFullKinematicContacts: 0
|
|
||||||
m_UseAutoMass: 0
|
|
||||||
m_Mass: 1
|
|
||||||
m_LinearDamping: 0
|
|
||||||
m_AngularDamping: 0.05
|
|
||||||
m_GravityScale: 1
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_Interpolate: 0
|
|
||||||
m_SleepingMode: 1
|
|
||||||
m_CollisionDetection: 0
|
|
||||||
m_Constraints: 4
|
|
||||||
--- !u!70 &335091084
|
|
||||||
CapsuleCollider2D:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 335091082}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 3
|
|
||||||
m_Density: 1
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_LayerOverridePriority: 0
|
|
||||||
m_ForceSendLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_ForceReceiveLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_ContactCaptureLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_CallbackLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_UsedByEffector: 0
|
|
||||||
m_CompositeOperation: 0
|
|
||||||
m_CompositeOrder: 0
|
|
||||||
m_Offset: {x: 0, y: 0.3}
|
|
||||||
m_Size: {x: 0.5, y: 0.7}
|
|
||||||
m_Direction: 0
|
|
||||||
--- !u!114 &335091087
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 335091082}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 9ba0864ae82c04db9a0ab083a089a388, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::PlayerMove
|
|
||||||
speed: 5
|
|
||||||
hp: 5
|
|
||||||
--- !u!1 &355728815
|
--- !u!1 &355728815
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -6534,19 +6451,27 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1812018419514169212, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
|
propertyPath: m_Avatar
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1812018419514169212, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
|
propertyPath: m_ApplyRootMotion
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents:
|
m_AddedComponents:
|
||||||
- targetCorrespondingSourceObject: {fileID: 103380811750077614, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 7794539611526692987, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 335091084}
|
addedObject: {fileID: 1652185991}
|
||||||
- targetCorrespondingSourceObject: {fileID: 103380811750077614, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 7794539611526692987, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 335091083}
|
addedObject: {fileID: 1652185990}
|
||||||
- targetCorrespondingSourceObject: {fileID: 103380811750077614, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 7794539611526692987, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 335091087}
|
addedObject: {fileID: 1652185989}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
--- !u!1 &681101986
|
--- !u!1 &681101986
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -29565,6 +29490,85 @@ Tilemap:
|
|||||||
e31: 0
|
e31: 0
|
||||||
e32: 0
|
e32: 0
|
||||||
e33: 1
|
e33: 1
|
||||||
|
--- !u!1 &1461597117
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1461597120}
|
||||||
|
- component: {fileID: 1461597119}
|
||||||
|
- component: {fileID: 1461597118}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: EventSystem
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1461597118
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1461597117}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.UI.InputSystemUIInputModule
|
||||||
|
m_SendPointerHoverToParent: 1
|
||||||
|
m_MoveRepeatDelay: 0.5
|
||||||
|
m_MoveRepeatRate: 0.1
|
||||||
|
m_XRTrackingOrigin: {fileID: 0}
|
||||||
|
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||||
|
m_DeselectOnBackgroundClick: 1
|
||||||
|
m_PointerBehavior: 0
|
||||||
|
m_CursorLockBehavior: 0
|
||||||
|
m_ScrollDeltaPerTick: 6
|
||||||
|
--- !u!114 &1461597119
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1461597117}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.EventSystems.EventSystem
|
||||||
|
m_FirstSelected: {fileID: 0}
|
||||||
|
m_sendNavigationEvents: 1
|
||||||
|
m_DragThreshold: 10
|
||||||
|
--- !u!4 &1461597120
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1461597117}
|
||||||
|
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 &1526470221
|
--- !u!1 &1526470221
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -29656,6 +29660,89 @@ SpriteRenderer:
|
|||||||
m_SpriteTileMode: 0
|
m_SpriteTileMode: 0
|
||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!1 &1652185985 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 7794539611526692987, guid: dc4d03e9834464d82a1dec0da2b8162f, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 598913983}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1652185989
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1652185985}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9ba0864ae82c04db9a0ab083a089a388, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::PlayerMove
|
||||||
|
speed: 5
|
||||||
|
hp: 5
|
||||||
|
--- !u!70 &1652185990
|
||||||
|
CapsuleCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1652185985}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_ForceSendLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ForceReceiveLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ContactCaptureLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_CallbackLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_CompositeOperation: 0
|
||||||
|
m_CompositeOrder: 0
|
||||||
|
m_Offset: {x: 0, y: 0.4}
|
||||||
|
m_Size: {x: 0.5, y: 1}
|
||||||
|
m_Direction: 0
|
||||||
|
--- !u!50 &1652185991
|
||||||
|
Rigidbody2D:
|
||||||
|
serializedVersion: 5
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1652185985}
|
||||||
|
m_BodyType: 0
|
||||||
|
m_Simulated: 1
|
||||||
|
m_UseFullKinematicContacts: 0
|
||||||
|
m_UseAutoMass: 0
|
||||||
|
m_Mass: 1
|
||||||
|
m_LinearDamping: 0
|
||||||
|
m_AngularDamping: 0.05
|
||||||
|
m_GravityScale: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_SleepingMode: 1
|
||||||
|
m_CollisionDetection: 0
|
||||||
|
m_Constraints: 4
|
||||||
--- !u!1 &1776863861
|
--- !u!1 &1776863861
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -45771,3 +45858,4 @@ SceneRoots:
|
|||||||
- {fileID: 300723960}
|
- {fileID: 300723960}
|
||||||
- {fileID: 2137532494}
|
- {fileID: 2137532494}
|
||||||
- {fileID: 403148642}
|
- {fileID: 403148642}
|
||||||
|
- {fileID: 1461597120}
|
||||||
|
|||||||
@@ -19,73 +19,88 @@ public class PlayerMove : MonoBehaviour
|
|||||||
// 컴포넌트 프로퍼티
|
// 컴포넌트 프로퍼티
|
||||||
public Rigidbody2D rb { get; private set; }
|
public Rigidbody2D rb { get; private set; }
|
||||||
|
|
||||||
private float maxSpeed;
|
// [수정] 동일한 오브젝트에 있는 SPUM_Prefabs를 가져옵니다.
|
||||||
|
private SPUM_Prefabs spumPrefab;
|
||||||
|
|
||||||
|
private float maxSpeed;
|
||||||
private Inputs _inputs;
|
private Inputs _inputs;
|
||||||
public Inputs Inputse => _inputs;
|
public Inputs Inputse => _inputs;
|
||||||
|
|
||||||
// 이동 관련 변수
|
// 이동 관련 변수
|
||||||
[SerializeField] private float speed = 5f; // 기본 속도 설정
|
[SerializeField] private float speed = 5f;
|
||||||
[SerializeField] public int hp = 5;
|
[SerializeField] public int hp = 5;
|
||||||
|
|
||||||
// 캐릭터의 기본 바라보는 방향 상태를 저장 (왼쪽 = true, 오른쪽 = false)
|
|
||||||
private bool isFacingRight = false;
|
private bool isFacingRight = false;
|
||||||
|
private int currentAnimationState = -1;
|
||||||
|
|
||||||
|
private Animator animator;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
// Rigidbody2D 컴포넌트 자동 할당
|
// 1. Rigidbody2D 할당
|
||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
|
|
||||||
// 캐릭터 방향 기본 오른쪽 설정 (기존 오타 수정: initailScale -> initialScale)
|
// 2. [수정] 같은 오브젝트에 붙어있으므로 GetComponent로 정확히 가져옵니다.
|
||||||
|
spumPrefab = GetComponentInParent<SPUM_Prefabs>();
|
||||||
|
// spumPrefab = GetComponent<SPUM_Prefabs>();
|
||||||
|
|
||||||
|
if (spumPrefab == null)
|
||||||
|
{
|
||||||
|
Debug.LogError($"{gameObject.name} 오브젝트에 SPUM_Prefabs 컴포넌트가 없습니다! 인스펙터를 확인하세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 캐릭터 방향 기본 오른쪽 설정
|
||||||
Vector3 initialScale = transform.localScale;
|
Vector3 initialScale = transform.localScale;
|
||||||
initialScale.x = Mathf.Abs(initialScale.x); // 확실하게 양수(오른쪽)로 초기화
|
initialScale.x = Mathf.Abs(initialScale.x);
|
||||||
transform.localScale = initialScale;
|
transform.localScale = initialScale;
|
||||||
|
|
||||||
|
animator = GetComponentInChildren<Animator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
InputContoller.UpdateInput(ref _inputs);
|
InputContoller.UpdateInput(ref _inputs);
|
||||||
|
|
||||||
// 입력값에 따른 방향 전환 체크
|
// 좌우 방향 전환 (Flip)
|
||||||
if (_inputs.PlayerMove.x < 0f && isFacingRight)
|
if (_inputs.PlayerMove.x < 0f && isFacingRight)
|
||||||
{
|
{
|
||||||
// 왼쪽 키를 누르고 있고, 현재 오른쪽을 보고 있다면 왼쪽으로 반전
|
|
||||||
Flip();
|
Flip();
|
||||||
}
|
}
|
||||||
else if (_inputs.PlayerMove.x > 0f && !isFacingRight)
|
else if (_inputs.PlayerMove.x > 0f && !isFacingRight)
|
||||||
{
|
{
|
||||||
// 오른쪽 키를 누르고 있고, 현재 왼쪽을 보고 있다면 오른쪽으로 반전
|
|
||||||
Flip();
|
Flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 애니메이션 업데이트 호출
|
||||||
|
if (_inputs.PlayerMove.x != 0f || _inputs.PlayerMove.y != 0f)
|
||||||
|
{
|
||||||
|
animator.SetBool("1_Move", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
animator.SetBool("1_Move", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.Z))
|
||||||
|
{
|
||||||
|
animator.SetTrigger("2_Attack");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
// 물리 연산 주기에 맞춰 실제로 캐릭터를 이동시킴
|
|
||||||
Move();
|
Move();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Move()
|
private void Move()
|
||||||
{
|
{
|
||||||
// rb가 비어있다면 이동 로직을 수행하지 않고 탈출
|
if (rb == null) return;
|
||||||
if (rb == null)
|
|
||||||
{
|
|
||||||
Debug.LogError($"{gameObject.name} 오브젝트에 Rigidbody2D 컴포넌트가 없습니다!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rb.linearVelocity = new Vector2(_inputs.PlayerMove.x * speed, rb.linearVelocity.y);
|
rb.linearVelocity = new Vector2(_inputs.PlayerMove.x * speed, rb.linearVelocity.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 캐릭터의 좌우 스케일을 반전시키는 메서드
|
|
||||||
/// </summary>
|
|
||||||
private void Flip()
|
private void Flip()
|
||||||
{
|
{
|
||||||
// 상태 스위칭
|
|
||||||
isFacingRight = !isFacingRight;
|
isFacingRight = !isFacingRight;
|
||||||
|
|
||||||
// localScale의 x축에 -1을 곱하여 반전
|
|
||||||
Vector3 scale = transform.localScale;
|
Vector3 scale = transform.localScale;
|
||||||
scale.x *= -1f;
|
scale.x *= -1f;
|
||||||
transform.localScale = scale;
|
transform.localScale = scale;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
PlayerSettings:
|
PlayerSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 28
|
serializedVersion: 28
|
||||||
productGUID: 00000000000000000000000000000000
|
productGUID: 9449050e69b954f89be1ef7eb32ea6cd
|
||||||
AndroidProfiler: 0
|
AndroidProfiler: 0
|
||||||
AndroidFilterTouchesWhenObscured: 0
|
AndroidFilterTouchesWhenObscured: 0
|
||||||
AndroidEnableSustainedPerformanceMode: 0
|
AndroidEnableSustainedPerformanceMode: 0
|
||||||
@@ -773,7 +773,8 @@ PlayerSettings:
|
|||||||
webGLCloseOnQuit: 0
|
webGLCloseOnQuit: 0
|
||||||
webWasm2023: 0
|
webWasm2023: 0
|
||||||
webEnableSubmoduleStrippingCompatibility: 0
|
webEnableSubmoduleStrippingCompatibility: 0
|
||||||
scriptingDefineSymbols: {}
|
scriptingDefineSymbols:
|
||||||
|
Standalone: ASSET_INVENTORY
|
||||||
additionalCompilerArguments: {}
|
additionalCompilerArguments: {}
|
||||||
platformArchitecture: {}
|
platformArchitecture: {}
|
||||||
scriptingBackend:
|
scriptingBackend:
|
||||||
|
|||||||
Reference in New Issue
Block a user