I'm having trouble with the score system on the skeet shooter game. My problem is that I don't know how to make each pigeon have a different score. I accomplished this on the tin cup game by tagging each row with separate tags and calling a different ChangeScore function when the target was hit. For example the first row was 20 pts, the second was 40, and the third 60. Seeing as all the enemies on the skeet shooter are all marked as Pigeon how would I make each pigeon pass a different score? I want the chicken, condor, and dragon to be 20, 40, and 100 points. I also typed in the code from the whiteboard and I'm getting an error on the PigeonHealth pointValue part. Unity says "the name pointValue does not exist in the current context."
Pigeon Health code
ChangeScore portion of GameManager
Pigeon Health code
Code:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PigeonHealth : MonoBehaviour { public int health = 100; public void DoDamage(int sentDamage) { health = health - sentDamage; if(health <= 0) { GameObject.Find("ScriptHolder").GetComponent<GameManager>().ChangeScore(pointValue); Destroy(gameObject); } } }
Code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; //using System; public class GameManager : MonoBehaviour { public Camera fpsCam; public int score; public Text scoreValue; public int highScore; public Text highScoreValue; [Header("General Stuff")] public string activeWeapon; [Header("Target Launcher")] public GameObject launcherBase; public GameObject launcher; public int remainingPigeons = 10; public Rigidbody[] pigeons; //creates array of pigeons public float pigeonSpeed = 10f; [Header("Pistol")] public GameObject pistolPivot; int activeChamber = 1; public bool canFirePistol; public Image shell01; public Image shell02; public Image shell03; public Image shell04; public Image shell05; public Image shell06; [Header("Rocket")] public GameObject rocketPivot; public Rigidbody rocket; public float rocketSpeed = 20f; public GameObject launchPoint; public Image rocketIndicator; public bool canFireRocket; [Header("PSM")] public GameObject psmPivot; public GameObject launchPointPSM; public Rigidbody psmRocket; public float psmRocketSpeed = 10f; public GameObject psm; public bool canFirePSM; public Image psmIndicator; public void ChangeScore(int sentScore) { score = score + sentScore; scoreValue.text = score.ToString(); if(score > highScore) { highScore = score; highScoreValue.GetComponent<Text>().text = highScore.ToString(); } }
Comment