Player movement - functional

This commit is contained in:
Sophie 2016-04-09 11:57:59 -04:00
parent 3abe330df1
commit ffb6237071
3 changed files with 14 additions and 24 deletions

View File

@ -200,23 +200,15 @@ public class Astronaut : MonoBehaviour {
public void Move(float x, float y) public void Move(float x, float y)
{ {
Vector3 pos = transform.position;
pos.z = 0;
float playerX, playerY; float playerX, playerY;
PlanetUtilities.Spheric2Cartesian(theta, height, out playerX, out playerY); PlanetUtilities.Spheric2Cartesian(theta - 108, height, out playerX, out playerY);
Debug.Log(theta); Vector3 pos = new Vector3(playerX, playerY);
//Vector3 v =
Vector3 dirV = Vector3.Cross(pos, Vector3.up).normalized; Vector3 dirV = Vector3.Cross(pos, Vector3.forward).normalized;
float proj = Vector3.Dot(new Vector3(x, y, 0), dirV); float proj = Vector3.Dot(new Vector3(x, y, 0), dirV);
//Debug.Log(proj / Time.deltaTime);
Debug.Log(dirV); float move = proj;
//float move = proj / Time.deltaTime; //Mathf.Abs(proj) < 0.1 ? 0 : proj;
float move = x;
if (State >= AstronautState.Ejecting ) if (State >= AstronautState.Ejecting )
return; return;
@ -237,11 +229,10 @@ public class Astronaut : MonoBehaviour {
if (State < AstronautState.Dashing) if (State < AstronautState.Dashing)
{ {
if (-0.2 < move && move < 0.2) return; if (-0.2 < move && move < 0.2) return;
//Debug.Log(x + " " + Speed + " " + height);
float movement = PlanetUtilities.GetDisplacementAngle(Speed * -move, height) * Time.deltaTime; float movement = PlanetUtilities.GetDisplacementAngle(Speed * -move, height) * Time.deltaTime;
//Debug.Log("Moving! - " + height);
//Debug.Log("Daaa - " + movement); float newTheta = Repeat(theta + movement, 360);
float newTheta = (360 + theta + movement) % 360; // angle positif
float newHeight = GetGroundRadius(newTheta); float newHeight = GetGroundRadius(newTheta);
if (newHeight > height) if (newHeight > height)
@ -257,15 +248,10 @@ public class Astronaut : MonoBehaviour {
//TODO arreter mouvement lateral //TODO arreter mouvement lateral
State=AstronautState.Idle; State=AstronautState.Idle;
} }
} }
public void Jump() public void Jump()
{ {
Debug.Log("Jump!");
if (State == AstronautState.Jumping) if (State == AstronautState.Jumping)
{ {
Dash(); Dash();
@ -278,9 +264,10 @@ public class Astronaut : MonoBehaviour {
else if (State >= AstronautState.Ejecting) else if (State >= AstronautState.Ejecting)
return; return;
if (!grounded) return;
_astronautAnimator.Jump(); // deja dans le property get/set _astronautAnimator.Jump(); // deja dans le property get/set
if (!grounded) return;
vSpeed = JumpSpeed; vSpeed = JumpSpeed;
grounded = false; grounded = false;
State = AstronautState.Jumping; State = AstronautState.Jumping;

View File

@ -277,8 +277,7 @@ public class PlanetManager : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public Wedge GetWedgeFromTheta(float thetaPlayerX) public Wedge GetWedgeFromTheta(float thetaPlayerX)
{ {
print(GetWedgeIndex((thetaPlayerX)%360)); return wedges[GetWedgeIndex((360 + thetaPlayerX) % 360)];
return wedges[GetWedgeIndex((thetaPlayerX) % 360)];
} }
/// <summary> /// <summary>

View File

@ -453,6 +453,10 @@ Prefab:
propertyPath: EjectSpinSpeed propertyPath: EjectSpinSpeed
value: 10 value: 10
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 154602, guid: acd71c7b2f995984d9033c9dc4e257dc, type: 2}
propertyPath: m_IsActive
value: 0
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