Here’s what I want to do:
Character 1 comes onscreen which has a score/rating. Then Character 2 comes onscreen which also has a score/rating.
If Character 1 has a higher score/rating, play animation ‘Victorious’ and Character 2 play animation ‘Defeat’. And vice-versa.
Anyone know how I would go about employing a score/rating system? Thanks
You could simple check it.
Grab the both scores and make a check and in that check place your animation call.
Ok, I’ve got this so far, which may help some people. I’ve got a script on ‘Car2’ like so:
using UnityEngine;
using System.Collections;
namespace Car{
public class WinLose1: MonoBehaviour {
public int Car2Speed = 205;
}
}
Then on ‘Car1’ I’ve got this script:
using UnityEngine;
using System.Collections;
using Car;
public class WinLose : MonoBehaviour {
public int Car1Speed = 196;
private GameObject Win;
private GameObject Lose;
public GameObject gameControllerObject;
public WinLose1 gameController;
void Start () {
Win = GameObject.Find ("Cube");
Lose = GameObject.Find ("Cylinder");
Win.SetActive(false);
Lose.SetActive(false);
gameControllerObject = GameObject.Find ("/ImageTarget2");
gameController = gameControllerObject.GetComponent<WinLose1>();
}
void Update () {
int NextCar = gameController.Car2Speed;
if(Car1Speed > NextCar){
Win.SetActive (true);
Lose.SetActive(false);
}
else{
Win.SetActive(false);
Lose.SetActive(true);
}
}
}
This accesses the other script and gets the int value which the determines whether to display the Cube or Cylinder (i.e. win or lose).
The next things I need to do are:
Make it only find the int value when the opponent is on screen. (OnTrackingFound?)
Make it reciprocal so they are looking for each others int values and displaying win or lose depending on each others values.
Alter the script so it’s not just reading from one external script but whichever script is attached to the model that comes on screen.
This is a lot more complicated than I originally thought but I’m determined to crack it now!