diff --git a/Assets/Resources/Player1.prefab b/Assets/Resources/Player1.prefab index 27feb4a..15b17ad 100644 --- a/Assets/Resources/Player1.prefab +++ b/Assets/Resources/Player1.prefab @@ -189,6 +189,7 @@ GameObject: - component: {fileID: 3878447480781341932} - component: {fileID: 1749848915408613053} - component: {fileID: 1949941092232239315} + - component: {fileID: 5302021185317648001} m_Layer: 7 m_Name: Player1 m_TagString: Player @@ -341,3 +342,16 @@ MonoBehaviour: movement: {x: 0, y: 0} look: {x: 0, y: 0} whipAttack: 0 + useArrowKeys: 0 +--- !u!114 &5302021185317648001 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index 2c95419..1e77040 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -189,6 +189,7 @@ GameObject: - component: {fileID: 3878447480781341932} - component: {fileID: 7071433868121438663} - component: {fileID: 1949941092232239315} + - component: {fileID: 4751086095402136128} m_Layer: 7 m_Name: Player2 m_TagString: Player @@ -341,3 +342,16 @@ MonoBehaviour: movement: {x: 0, y: 0} look: {x: 0, y: 0} whipAttack: 0 + useArrowKeys: 0 +--- !u!114 &4751086095402136128 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3120938410244321186} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c66441ada081b6c4c841000e83cc2b7a, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scripts/Player/PlayerAnimationHandler.cs b/Assets/Scripts/Player/PlayerAnimationHandler.cs index f26e30f..13a8fa5 100644 --- a/Assets/Scripts/Player/PlayerAnimationHandler.cs +++ b/Assets/Scripts/Player/PlayerAnimationHandler.cs @@ -5,30 +5,12 @@ using UnityEngine; public class PlayerAnimationHandler : MonoBehaviour { Animator animator; - SpriteRenderer sp; - - Vector3 prevPos; void Start() { animator = GetComponentInChildren(); - sp = GetComponentInChildren(); } - private void Update() - { - if ((transform.position - prevPos).x > 0.1f) - { - sp.flipX = false; - } - else if ((transform.position - prevPos).x < -0.1f) - { - sp.flipX = true; - } - - prevPos = transform.position; - } - public void Idle() { animator.SetTrigger("Idle"); diff --git a/Assets/Scripts/Player/SpriteMovementFlipper.cs b/Assets/Scripts/Player/SpriteMovementFlipper.cs new file mode 100644 index 0000000..cf33f64 --- /dev/null +++ b/Assets/Scripts/Player/SpriteMovementFlipper.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +public class SpriteMovementFlipper : MonoBehaviour +{ + SpriteRenderer sp; + + Vector3 prevPos; + + void Start() + { + sp = GetComponentInChildren(); + } + + private void Update() + { + if ((transform.position - prevPos).x > 0.1f) + { + sp.flipX = false; + } + else if ((transform.position - prevPos).x < -0.1f) + { + sp.flipX = true; + } + + prevPos = transform.position; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta b/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta new file mode 100644 index 0000000..c555aef --- /dev/null +++ b/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c66441ada081b6c4c841000e83cc2b7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: