Fixed player death launch
This commit is contained in:
@@ -6,7 +6,11 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings;
|
||||
public static void AttachPlayer() { s_Instance.m_OrbitalPosition.m_IsAttachedToRings = true; }
|
||||
|
||||
public Rigidbody2D m_Body;
|
||||
private Vector3 m_SuicidePoint;
|
||||
private bool m_KillingItself = false;
|
||||
private float m_DeathLerp = 0f;
|
||||
|
||||
public MeshRenderer m_Renderer;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
@@ -17,7 +21,7 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.4f;
|
||||
m_OrbitalPosition.m_SpinSpeed = 0.2f;
|
||||
}
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space) && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||
@@ -25,23 +29,29 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
m_OrbitalPosition.m_AttachedRing += 1;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
OnCollision(null); // Fake collision
|
||||
}
|
||||
if (!m_KillingItself)
|
||||
return;
|
||||
|
||||
transform.position = Vector3.Lerp(m_SuicidePoint, Vector3.zero, m_DeathLerp);
|
||||
m_DeathLerp += Time.deltaTime;
|
||||
|
||||
}
|
||||
|
||||
public override void OnCollision(OrbitalPositionBehaviour other)
|
||||
{
|
||||
GlobalOrbitalPositionManager.RestartSimulation();
|
||||
|
||||
if (!m_OrbitalPosition.m_IsAttachedToRings)
|
||||
return;
|
||||
|
||||
GlobalOrbitalPositionManager.RestartSimulation();
|
||||
m_SuicidePoint = transform.position;
|
||||
m_KillingItself = true;
|
||||
m_DeathLerp = 0f;
|
||||
}
|
||||
|
||||
m_OrbitalPosition.m_IsAttachedToRings = false;
|
||||
Vector3 direction = (-transform.position).normalized;
|
||||
m_Body.AddForce(direction * 5f, ForceMode2D.Impulse);
|
||||
|
||||
public override void OnSimulationRestart()
|
||||
{
|
||||
m_KillingItself = false;
|
||||
m_Renderer.enabled = true;
|
||||
}
|
||||
|
||||
public override void OnReachCentre()
|
||||
|
||||
Reference in New Issue
Block a user