Question by
ninjixfatality · Apr 06, 2018 at 04:00 AM ·
unity 5score systemammo
How to turn score points into ammo amount?
I'm making a game where if you collect a fish you gain a point. What I want is that the point you gain will also be equivalent to how much ammo the player has to shoot these fish to a bird that hovers in the air.
Any way I can write this or an example? Do I add a public text and drag the score text into there and start from there. I also want that for every shot there is a -1 from the score. Thank you in advance I'm new to C#!
GameObject Bullet;
// Use this for initialization
void Start () {
Bullet = Resources.Load ("projectile") as GameObject;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("f"))
{
GameObject projectile = Instantiate (Bullet) as GameObject;
projectile.transform.position = transform.position + Camera.main.transform.forward * 2;
Rigidbody rb = projectile.GetComponent<Rigidbody> ();
rb.velocity = Camera.main.transform.forward * 40;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
how to refresh the a scene without reloading it? 1 Answer
Scoring Points with UI Text 0 Answers
how to check how much distance the player covered. 1 Answer
Can't score points 1 Answer