I was wondering if anyone could just lend me a moment of there time to help me with a simple problem.
I’ve being using the Free Fantasy AI that you can download from the unity asset store, within the game package there is a health script that I have being working on. Within the health script I was able to add a destroy script that would destroy the player gameobject once his/her health is gone.
However the problem I’m having is that I wish to have either the player respawn back at his/her spawn point OR either have the level completely restart?
If anyone could give me some help that would be great. Just in case anyone is wondering that script below is the health script that from the Free Fantasy AI…
public class Health : MonoBehaviour {
public float MaxHealth=100;
public float CurrentHealth;
public bool Invincible;
public bool Dead;
// Use this for initialization
void Start () {
//MAKE THE CURRENT HEALTH THE MAX HEALTH AT START
CurrentHealth=MaxHealth;
}
// Update is called once per frame
void Update () {
//IF INVINCIBLE, HE CANNOT DIE..
if(Invincible){
CurrentHealth=MaxHealth;
}
else{
if(CurrentHealth<=0){
CurrentHealth=0;
Dead=true;
}
//MAX HEALTH
if(CurrentHealth>=MaxHealth)CurrentHealth=MaxHealth;
//WHEN DEATH IS UPON HIM
if(Dead){
Destroy(gameObject);
//TELL THE AI SCRIPT HE IS DEAD
FreeAI AI=(FreeAI)GetComponent("FreeAI");
if(AI){
if(AI.IsDead){}
else AI.IsDead=true;
}
}
}
}
}
Go dtí an chéad uair eile, slán leat
Saying “ForceMode.Impulse == Force per frame” is totally wrong. The author even realized it by himself by saying "It will only be applied at the instant you call the function". ---------- I am tired to explain this again, Unity physics is bad physics because those Forcemodes were not correctly implemented as it sounds. ---------- Basically, they are all the same method, two of them have 50x speed(50 physics frame in a second) multiplier, two of them include Mass.
– anon5910573