Hi,
Hope you can help on this. I am trying to see if there is something in Opsive that may help with this issue or integrate into my own code anything that may work like life counter method system.
I have my own health method works really well, just health bar method when depleted returns to main menu after player dies scene gets re-set.
However I have tried to devise a system for 'lives remaining'. i.e 3 Icons displayed, then dies player has 2 lives then 1 live, then player finally dies returns to main menu.
before 'Game Over' message displays back to main menu.
I have experimented with Opsives re-spawner script (which is automatically added to player on Opsive set up). Clicked scheduled respawn on death (matched the respawn to 2 seconds tried various other numbers too), so the code doesn't re-set (rather than load my entire scene on death). If there is a way to keep a count here before re-spawn x 3 then return to main menu?
This works well in the sense the player lives Icons are not going to be re-set (information is retained) and are behaving how I would expect.
For lives Icons I have used Opsive running Icon to represent a life. The issue I'm having though is the death animation gets cancelled and huge delays (20 seconds before main menu). The player stops responding to damage occasionally basically it stops working so well. Is there a better method? Am I on the right tracks here as far as own lives system concerned? I'm not sure if I am approaching this the right way, just a bit guess work trial and error really.
public GameObject Live1;// the image icon I have used Opsive running Icon to represent lives
public GameObject Live2;
public GameObject Live3;
private bool threeLives;// defines what happens under condition threeLives
private bool twoLives;// defines what happens under condition twoLives etc
private bool oneLive;
void OnTriggerEnter(Collider other)//
{
if (playerCurrentHealth < 0 && !isDead) //
// if (other.tag == "Player destroy" && !isDead) // if player is dead 'tag condition' the following function below happen
{
{
var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();//Opsive API method
var dieAbility = characterLocomotion.GetAbility<Die>();
characterLocomotion.TryStartAbility(dieAbility);//Opsive API method
StartCoroutine(delay(v: 30));// set delay function in motion
Gameover.enabled = true;// text to annouce game over
isDead = true;// bool to indicate the above actions represent is dead.i.e less than 0 and is dead the above events happens }
IEnumerator delay(int v) // need to switch off respawn
{
if (playerCurrentHealth < 0 && !isDead & twoLives)
{
Live2.SetActive(false);
oneLive=true;
}
if (playerCurrentHealth < 0 && !isDead & oneLives)
{
yield return new WaitForSeconds(2.0f);//
Live1.SetActive(false);
Gameover.enabled = true;//
isDead = true;
SceneManager.LoadScene(loadLevel);//
Time.timeScale = 0;
}
yield return new WaitForSeconds(2.5f);// This point player spawn back to life 2.5f matching Opsive respawn counter too
isDead = false;// important to bring to life again or conditions under isDead will remain
Live3.SetActive(false);
twoLives = true;
GetComponent<PlayerhealthPR>().HurtPlayer(-1000);//The Player gets health back as script no longer re-loading with new lives method
Hope you can help on this. I am trying to see if there is something in Opsive that may help with this issue or integrate into my own code anything that may work like life counter method system.
I have my own health method works really well, just health bar method when depleted returns to main menu after player dies scene gets re-set.
However I have tried to devise a system for 'lives remaining'. i.e 3 Icons displayed, then dies player has 2 lives then 1 live, then player finally dies returns to main menu.
before 'Game Over' message displays back to main menu.
I have experimented with Opsives re-spawner script (which is automatically added to player on Opsive set up). Clicked scheduled respawn on death (matched the respawn to 2 seconds tried various other numbers too), so the code doesn't re-set (rather than load my entire scene on death). If there is a way to keep a count here before re-spawn x 3 then return to main menu?
This works well in the sense the player lives Icons are not going to be re-set (information is retained) and are behaving how I would expect.
For lives Icons I have used Opsive running Icon to represent a life. The issue I'm having though is the death animation gets cancelled and huge delays (20 seconds before main menu). The player stops responding to damage occasionally basically it stops working so well. Is there a better method? Am I on the right tracks here as far as own lives system concerned? I'm not sure if I am approaching this the right way, just a bit guess work trial and error really.
public GameObject Live1;// the image icon I have used Opsive running Icon to represent lives
public GameObject Live2;
public GameObject Live3;
private bool threeLives;// defines what happens under condition threeLives
private bool twoLives;// defines what happens under condition twoLives etc
private bool oneLive;
void OnTriggerEnter(Collider other)//
{
if (playerCurrentHealth < 0 && !isDead) //
// if (other.tag == "Player destroy" && !isDead) // if player is dead 'tag condition' the following function below happen
{
{
var characterLocomotion = m_Character.GetComponent<UltimateCharacterLocomotion>();//Opsive API method
var dieAbility = characterLocomotion.GetAbility<Die>();
characterLocomotion.TryStartAbility(dieAbility);//Opsive API method
StartCoroutine(delay(v: 30));// set delay function in motion
Gameover.enabled = true;// text to annouce game over
isDead = true;// bool to indicate the above actions represent is dead.i.e less than 0 and is dead the above events happens }
IEnumerator delay(int v) // need to switch off respawn
{
if (playerCurrentHealth < 0 && !isDead & twoLives)
{
Live2.SetActive(false);
oneLive=true;
}
if (playerCurrentHealth < 0 && !isDead & oneLives)
{
yield return new WaitForSeconds(2.0f);//
Live1.SetActive(false);
Gameover.enabled = true;//
isDead = true;
SceneManager.LoadScene(loadLevel);//
Time.timeScale = 0;
}
yield return new WaitForSeconds(2.5f);// This point player spawn back to life 2.5f matching Opsive respawn counter too
isDead = false;// important to bring to life again or conditions under isDead will remain
Live3.SetActive(false);
twoLives = true;
GetComponent<PlayerhealthPR>().HurtPlayer(-1000);//The Player gets health back as script no longer re-loading with new lives method
Last edited: