I have a empty game object called "SpawnPoint". Obviously you probably know what im going to ask. I want people once there health = 0 to teleport here. Here is my script at this moment.
using UnityEngine;
using System.Collections;
public class JobInfo : MonoBehaviour {
public int curMoney = 1000;
public int curHealth = 100;
public int maxHealth = 100;
public string curJob;
public int Salary = 50;
public int payTime = 180;
public float healthBarLength;
void Start () {
InvokeRepeating ("AddMoney", payTime, payTime);
healthBarLength = Screen.width / 2;
}
// Update is called once per frame
void Update () {
AdjustCurrentHealth(0);
}
void OnGUI() {
GUI.Label (new Rect (10, 10, 100, 30), "Job: ");
GUI.Label (new Rect (35, 10, 100, 30), curJob);
GUI.Label (new Rect (85, 10, 100, 30), "Salary: ");
GUI.Label (new Rect (125, 10, 100, 30), Salary.ToString());
GUI.Label (new Rect (155, 10, 100, 30), "Money: ");
GUI.Label (new Rect (200, 10, 100, 30), curMoney.ToString());
GUI.Box(new Rect(10, Screen.height - 30, healthBarLength, 20), curHealth + "/" + maxHealth);
}
public void AdjustCurrentHealth(int adj) {
curHealth +=adj;
if(curHealth < 1)
curHealth = 0;
if(curHealth > maxHealth)
curHealth = maxHealth;
if(maxHealth < 1)
maxHealth = 1;
healthBarLength = (Screen.width / 2) * (curHealth / (float)maxHealth);
}
void AddMoney ()
{
curMoney += Salary;
}
}
Im guessing that it should start out like this...
if(curHealth = 0)
than something here.
I know ill need a variable, most likely or just to make stuff easier so would the variable look something like this?
public GameObject PlayerSpawn;
or would the variable have anything to do with Vector3?
Im just looking for help and want to understand this more.
The SpawPoint is located at
X: 1613.222
Y: 1
Z: 1548.858