mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 10:30:59 +00:00
Walking animation
This commit is contained in:
parent
803bd94c77
commit
990560f27a
@ -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
|
||||
|
||||
@ -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 {
|
||||
/// </summary>
|
||||
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();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user