diff --git a/Assets/Prefabs/Astronaut.prefab b/Assets/Prefabs/Astronaut.prefab index df5704a..3dfd265 100644 --- a/Assets/Prefabs/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut.prefab @@ -145,7 +145,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ab270b0cb2475114ab8eb45661af0df1, type: 3} m_Name: m_EditorClassIdentifier: - PlayerNumber: 1 + PlayerNumber: 0 --- !u!114 &11491252 MonoBehaviour: m_ObjectHideFlags: 1 @@ -158,8 +158,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: aspi: {fileID: 0} - WalkAnimSpeed: 0 - WalkAnimAngle: 0 + WalkAnimSpeed: 4 + WalkAnimAngle: 15 EjectSpinSpeed: 80 DustParticlesEmitter: {fileID: 138982, guid: 6233079c5a9a756458811f283fdca112, type: 2} --- !u!114 &11494368 diff --git a/Assets/Scripts/Astronaut.cs b/Assets/Scripts/Astronaut.cs index 8bcb149..de19cf0 100644 --- a/Assets/Scripts/Astronaut.cs +++ b/Assets/Scripts/Astronaut.cs @@ -56,11 +56,10 @@ public class Astronaut : MonoBehaviour { SpriteDash.gameObject.SetActive(false); }*/ - /*if (_state == AstronautState.Walking) + if (State == AstronautState.Walking) { - //StartCoroutine(WalkingStance()); - _astronautAnimator.Walk(); - }*/ + _astronautAnimator.Walk(walkRight); + } } } @@ -68,6 +67,7 @@ public class Astronaut : MonoBehaviour { private float height = 0; private float vSpeed = 0; private bool grounded = false; + private bool walkRight = false; private float walkTime = 0; private int nextStep = 1; @@ -221,6 +221,7 @@ public class Astronaut : MonoBehaviour { } else { + walkRight = move > 0; State = AstronautState.Walking; walkTime = 0f; } @@ -237,7 +238,7 @@ public class Astronaut : MonoBehaviour { float newHeight = GetGroundRadius(newTheta); if (newHeight > height) { - Debug.Log("Blocked by wall"); + //Debug.Log("Blocked by wall"); return; // Blocked by wall } @@ -303,7 +304,7 @@ public class Astronaut : MonoBehaviour { /// public void Stun() { - print("Stunned"); + //print("Stunned"); } public void OnGUI() @@ -311,7 +312,14 @@ public class Astronaut : MonoBehaviour { if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString())) { Debug.Log("Clicked the button with an image"); - Eject(); - } + //_astronautAnimator.Walk(); + //Eject(); + } + /* if (GUI.Button(new Rect(60, 10, 150, 50), "Stop")) + { + Debug.Log("Clicked the button with an image"); + _astronautAnimator.StopWalk(); + //Eject(); + }*/ } } diff --git a/Assets/Scripts/AstronautAnimator.cs b/Assets/Scripts/AstronautAnimator.cs index c2dc410..979d237 100644 --- a/Assets/Scripts/AstronautAnimator.cs +++ b/Assets/Scripts/AstronautAnimator.cs @@ -39,9 +39,10 @@ public class AstronautAnimator : MonoBehaviour { aspi.SpriteDash.gameObject.SetActive(false); } - public void Walk() + public void Walk(bool right) { - StartCoroutine(Rotate()); + Debug.Log("Walking!"); + StartCoroutine(Rotate(right? -1 : 1)); } public void Eject() @@ -58,9 +59,9 @@ public class AstronautAnimator : MonoBehaviour { } } - IEnumerator Rotate() + IEnumerator Rotate(float side) { - for (float i = 0.5f; i < 2.5f; i+= Time.deltaTime*WalkAnimSpeed) + for (float i = 0.5f; i < 1.5f; i+= Time.deltaTime*WalkAnimSpeed) { /*int roundDown = 10; //0.5, 1.5 et 2.5 @@ -70,15 +71,18 @@ public class AstronautAnimator : MonoBehaviour { aspi.SpriteWalk.flipX = !aspi.SpriteWalk.flipX; }*/ float position = Mathf.PingPong(i, 1f); - transform.rotation = Quaternion.Euler(0, 0, (position - 0.5f) * WalkAnimAngle * 2); + transform.localRotation = Quaternion.Euler(0, 0, side * (position - 0.5f) * WalkAnimAngle * 2); yield return null; } if (aspi.State == Astronaut.AstronautState.Walking) { - StartCoroutine(Rotate()); + Debug.Log("Walking again"); + StartCoroutine(Rotate(-side)); } - yield return null; + else + Debug.Log("Walking stop"); + //yield return null; } public void EmitDustParticules() diff --git a/Assets/_Scenes/Main.unity b/Assets/_Scenes/Main.unity index b6fb9e7..4d45db9 100644 --- a/Assets/_Scenes/Main.unity +++ b/Assets/_Scenes/Main.unity @@ -132,10 +132,6 @@ Prefab: propertyPath: m_Name value: Astronaut_0 objectReference: {fileID: 0} - - target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} - propertyPath: PlayerNumber - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0 @@ -515,6 +511,10 @@ Prefab: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 11434752, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} + propertyPath: PlayerNumber + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2} m_IsPrefabParent: 0