mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-25 19:10:58 +00:00
player movement - dash & eject
This commit is contained in:
parent
9468107334
commit
e755120ef0
@ -18,6 +18,8 @@ public class Astronaut : MonoBehaviour {
|
|||||||
public float JumpSpeed;
|
public float JumpSpeed;
|
||||||
public float Gravity;
|
public float Gravity;
|
||||||
public float Speed;
|
public float Speed;
|
||||||
|
public float EjectSpeed;
|
||||||
|
public float DashSpeed;
|
||||||
|
|
||||||
public PlanetManager planet;
|
public PlanetManager planet;
|
||||||
|
|
||||||
@ -106,15 +108,27 @@ public class Astronaut : MonoBehaviour {
|
|||||||
if (!grounded)
|
if (!grounded)
|
||||||
{
|
{
|
||||||
height += vSpeed * delta;
|
height += vSpeed * delta;
|
||||||
vSpeed -= Gravity * delta;
|
if (State != AstronautState.Ejecting)
|
||||||
|
vSpeed -= Gravity * delta;
|
||||||
|
else
|
||||||
|
vSpeed *= 0.98f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float radius = GetGroundRadius();
|
float radius = GetGroundRadius();
|
||||||
if (grounded = (height <= radius))
|
if (grounded = (height <= radius))
|
||||||
{
|
{
|
||||||
|
if (State == AstronautState.Dashing)
|
||||||
|
{
|
||||||
|
planet.PushWedge(Repeat(theta,360));
|
||||||
|
State = AstronautState.Idle;
|
||||||
|
//TODO_SR Create dash impact here
|
||||||
|
}
|
||||||
|
|
||||||
height = radius;
|
height = radius;
|
||||||
if (State == AstronautState.Jumping)
|
if (State == AstronautState.Jumping)
|
||||||
State = AstronautState.Idle;
|
State = AstronautState.Idle;
|
||||||
|
|
||||||
|
vSpeed = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
@ -208,12 +222,25 @@ public class Astronaut : MonoBehaviour {
|
|||||||
{
|
{
|
||||||
if (_state >= AstronautState.Ejecting)
|
if (_state >= AstronautState.Ejecting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
State = AstronautState.Dashing;
|
||||||
|
vSpeed = -DashSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Eject()
|
||||||
|
{
|
||||||
|
State = AstronautState.Ejecting;
|
||||||
|
vSpeed = EjectSpeed;
|
||||||
|
grounded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGUI()
|
public void OnGUI()
|
||||||
{
|
{
|
||||||
if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString()))
|
if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString()))
|
||||||
|
{
|
||||||
Debug.Log("Clicked the button with an image");
|
Debug.Log("Clicked the button with an image");
|
||||||
|
Eject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*IEnumerator WalkingStance()
|
/*IEnumerator WalkingStance()
|
||||||
|
|||||||
@ -572,6 +572,14 @@ Prefab:
|
|||||||
propertyPath: Width
|
propertyPath: Width
|
||||||
value: 0.4
|
value: 0.4
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||||
|
propertyPath: EjectSpeed
|
||||||
|
value: 15
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 11494368, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||||
|
propertyPath: DashSpeed
|
||||||
|
value: 12
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
m_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
|
||||||
m_IsPrefabParent: 0
|
m_IsPrefabParent: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user