player movement - dash & eject

This commit is contained in:
RosimInc 2016-04-08 19:53:04 -04:00
parent 9468107334
commit e755120ef0
2 changed files with 36 additions and 1 deletions

View File

@ -18,6 +18,8 @@ public class Astronaut : MonoBehaviour {
public float JumpSpeed;
public float Gravity;
public float Speed;
public float EjectSpeed;
public float DashSpeed;
public PlanetManager planet;
@ -106,15 +108,27 @@ public class Astronaut : MonoBehaviour {
if (!grounded)
{
height += vSpeed * delta;
vSpeed -= Gravity * delta;
if (State != AstronautState.Ejecting)
vSpeed -= Gravity * delta;
else
vSpeed *= 0.98f;
}
float radius = GetGroundRadius();
if (grounded = (height <= radius))
{
if (State == AstronautState.Dashing)
{
planet.PushWedge(Repeat(theta,360));
State = AstronautState.Idle;
//TODO_SR Create dash impact here
}
height = radius;
if (State == AstronautState.Jumping)
State = AstronautState.Idle;
vSpeed = 0f;
}
UpdatePosition();
@ -208,12 +222,25 @@ public class Astronaut : MonoBehaviour {
{
if (_state >= AstronautState.Ejecting)
return;
State = AstronautState.Dashing;
vSpeed = -DashSpeed;
}
public void Eject()
{
State = AstronautState.Ejecting;
vSpeed = EjectSpeed;
grounded = false;
}
public void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 150, 50), State.ToString()))
{
Debug.Log("Clicked the button with an image");
Eject();
}
}
/*IEnumerator WalkingStance()

View File

@ -572,6 +572,14 @@ Prefab:
propertyPath: Width
value: 0.4
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_ParentPrefab: {fileID: 100100000, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
m_IsPrefabParent: 0