Fixed player death launch
This commit is contained in:
@@ -134,7 +134,6 @@ GameObject:
|
|||||||
- component: {fileID: 104400497}
|
- component: {fileID: 104400497}
|
||||||
- component: {fileID: 104400501}
|
- component: {fileID: 104400501}
|
||||||
- component: {fileID: 104400500}
|
- component: {fileID: 104400500}
|
||||||
- component: {fileID: 104400502}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -162,7 +161,7 @@ MonoBehaviour:
|
|||||||
m_IsAttachedToRings: 0
|
m_IsAttachedToRings: 0
|
||||||
m_Behaviour: {fileID: 0}
|
m_Behaviour: {fileID: 0}
|
||||||
m_SpinSpeed: 0
|
m_SpinSpeed: 0
|
||||||
m_Body: {fileID: 104400502}
|
m_Renderer: {fileID: 104400500}
|
||||||
--- !u!4 &104400498
|
--- !u!4 &104400498
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -228,33 +227,6 @@ MeshFilter:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 104400496}
|
m_GameObject: {fileID: 104400496}
|
||||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
--- !u!50 &104400502
|
|
||||||
Rigidbody2D:
|
|
||||||
serializedVersion: 4
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 104400496}
|
|
||||||
m_BodyType: 0
|
|
||||||
m_Simulated: 1
|
|
||||||
m_UseFullKinematicContacts: 0
|
|
||||||
m_UseAutoMass: 0
|
|
||||||
m_Mass: 1
|
|
||||||
m_LinearDrag: 0
|
|
||||||
m_AngularDrag: 0.05
|
|
||||||
m_GravityScale: 0
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_Interpolate: 1
|
|
||||||
m_SleepingMode: 1
|
|
||||||
m_CollisionDetection: 0
|
|
||||||
m_Constraints: 0
|
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -89,8 +89,12 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
if (PlayerController.IsPlayerAttached)
|
if (PlayerController.IsPlayerAttached)
|
||||||
s_Instance.m_PlayerOrbitalPosition.m_AttachedRing = s_Instance.m_LastGeneratedRing;
|
s_Instance.m_PlayerOrbitalPosition.m_AttachedRing = s_Instance.m_LastGeneratedRing;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.AttachPlayer();
|
PlayerController.AttachPlayer();
|
||||||
|
foreach (OrbitalPosition behaviour in s_Instance.m_ObjectInstances)
|
||||||
|
{
|
||||||
|
behaviour.m_Behaviour.OnSimulationRestart();
|
||||||
|
}
|
||||||
|
|
||||||
yield return new WaitForSeconds(1.3f);
|
yield return new WaitForSeconds(1.3f);
|
||||||
AllowPlayerInput = true;
|
AllowPlayerInput = true;
|
||||||
@@ -223,4 +227,6 @@ public abstract class OrbitalPositionBehaviour : MonoBehaviour
|
|||||||
public virtual void OnReachCentre() { }
|
public virtual void OnReachCentre() { }
|
||||||
|
|
||||||
public virtual void OnCollision(OrbitalPositionBehaviour other) { }
|
public virtual void OnCollision(OrbitalPositionBehaviour other) { }
|
||||||
|
|
||||||
|
public virtual void OnSimulationRestart() { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings;
|
public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings;
|
||||||
public static void AttachPlayer() { s_Instance.m_OrbitalPosition.m_IsAttachedToRings = true; }
|
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()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
@@ -17,7 +21,7 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
m_OrbitalPosition.m_ObjectRadius = 0.4f;
|
m_OrbitalPosition.m_ObjectRadius = 0.4f;
|
||||||
m_OrbitalPosition.m_SpinSpeed = 0.2f;
|
m_OrbitalPosition.m_SpinSpeed = 0.2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(KeyCode.Space) && GlobalOrbitalPositionManager.AllowPlayerInput)
|
if (Input.GetKeyDown(KeyCode.Space) && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||||
@@ -25,23 +29,29 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
m_OrbitalPosition.m_AttachedRing += 1;
|
m_OrbitalPosition.m_AttachedRing += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.R))
|
if (!m_KillingItself)
|
||||||
{
|
return;
|
||||||
OnCollision(null); // Fake collision
|
|
||||||
}
|
transform.position = Vector3.Lerp(m_SuicidePoint, Vector3.zero, m_DeathLerp);
|
||||||
|
m_DeathLerp += Time.deltaTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnCollision(OrbitalPositionBehaviour other)
|
public override void OnCollision(OrbitalPositionBehaviour other)
|
||||||
{
|
{
|
||||||
GlobalOrbitalPositionManager.RestartSimulation();
|
|
||||||
|
|
||||||
if (!m_OrbitalPosition.m_IsAttachedToRings)
|
if (!m_OrbitalPosition.m_IsAttachedToRings)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GlobalOrbitalPositionManager.RestartSimulation();
|
||||||
|
m_SuicidePoint = transform.position;
|
||||||
|
m_KillingItself = true;
|
||||||
|
m_DeathLerp = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
m_OrbitalPosition.m_IsAttachedToRings = false;
|
public override void OnSimulationRestart()
|
||||||
Vector3 direction = (-transform.position).normalized;
|
{
|
||||||
m_Body.AddForce(direction * 5f, ForceMode2D.Impulse);
|
m_KillingItself = false;
|
||||||
|
m_Renderer.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnReachCentre()
|
public override void OnReachCentre()
|
||||||
|
|||||||
Reference in New Issue
Block a user