Hello! I am trying to make an AR game, where the player has to shoot some skulls, and I created a game object which it is a Blue Skull
Right now the player will get +1 to his score if they destroy either a white skull or blue skull.
How can I make that the player can get +2 to his score?
I have this script so far:
public void shoot() {
RaycastHit hit;
if(Physics.Raycast(arCamera.transform.position, arCamera.transform.forward, out hit)) {
if (hit.transform.name == "whiteSkull(Clone)" || hit.transform.name == "blueSkull(Clone)" ; { //Esto es para especificar que va a pasar si el jugador "dispara" contra cierto game object del juego
Destroy(hit.transform.gameObject);
Instantiate(smoke, hit.point, Quaternion.LookRotation(hit.normal));
AddScore();
}
}
}
void AddScore()
{
Score++;
scoreText.text = Score.ToString();
}
One of the solutions that I have been thinking is to separate the code like this:
if(Physics.Raycast(arCamera.transform.position, arCamera.transform.forward, out hit)) {
if (hit.transform.name == "whiteSkull(Clone)" || hit.transform.name == "blueSkull(Clone)" || hit.transform.name == "ballon2(Clone)"); { //Esto es para especificar que va a pasar si el jugador "dispara" contra cierto game object del juego
Destroy(hit.transform.gameObject);
Instantiate(smoke, hit.point, Quaternion.LookRotation(hit.normal));
AddScore();
}
if (hit.transform.name == "blueSkull(Clone)"); { //Esto es para especificar que va a pasar si el jugador "dispara" contra cierto game object del juego
Destroy(hit.transform.gameObject);
Instantiate(smoke, hit.point, Quaternion.LookRotation(hit.normal));
AddScore();
}
}
}
void AddScore()
{
Score++;
scoreText.text = Score.ToString();
}
But I do not have any idea on how to make that blue skull to give double points.