Hello, Im working on a Zombie Game similar to Call of Duty type zombie game mode.
I have a map set up, along with my fps,fully working guns, and zombies that die when shot.
unfortunately i need to add a points system like a GUI text or something to stay on the players screen, displaying how many points they have obtained. (10 points per zombie)
i have also set up barriers in key points of the map where players cain’t travel through. I need to know
.How to add a points system along with GUI text.
.How to add 10 points to the players score when a zombie is killed.
. How to delete a barrier for set points while subtracting the points from players score like a “Cost” to remove the barrier.
If anyone could lead me towards the right direction on how achieve this is would be very grateful. sadly i don’t have much knowledge of scripting. so a full script would be very very very helpful. if its too much to ask for a script than a worded tutorial would also be very helpful.
Here is the script for the health and death for zombies (i don’t really know if this would help but…)
//Applies damage to NPCs
using UnityEngine;
using System.Collections;
public class CharacterDamage : MonoBehaviour {
public float hitPoints = 100.0f;
public Transform deadReplacement;
public AudioClip dieSound;
public bool removeBody;
public float bodyStayTime = 15.0f;
private Vector3 attackerPos2;
private Vector3 attackDir2;
private Transform myTransform;
//set ray mask to layer 9, the ragdoll layer
//for applying force to specific ragdoll limbs
private LayerMask raymask = 1 << 9;
void Start (){
myTransform = transform;
}
//damage NPC
public void ApplyDamage ( float damage, Vector3 attackDir, Vector3 attackerPos ){
if (hitPoints <= 0.0f){
return;
}
hitPoints -= damage;
attackDir2 = attackDir;
attackerPos2 = attackerPos;
//expand enemy search radius if attacked outside default search radius to defend against sniping
if(transform.GetComponent()){
transform.GetComponent().attackRange = transform.GetComponent().attackRange * 3;
}
if (hitPoints <= 0.0f){
SendMessage(“Die”);//use SendMessage() to allow other script components on this object to detect NPC death
}
}
void Die (){
RaycastHit rayHit;
// Play a dying audio clip
if (dieSound){
AudioSource.PlayClipAtPoint(dieSound, transform.position);
}
// Replace ourselves with the dead body
if (deadReplacement) {
Transform dead = Instantiate(deadReplacement, transform.position, transform.rotation) as Transform;
// Copy position rotation from the old hierarchy into the dead replacement
CopyTransformsRecurse(transform, dead);
//apply damage force to NPC ragdoll if being damaged by player
if(Physics.SphereCast(attackerPos2, 0.2f, attackDir2, out rayHit, 750.0f, raymask)
rayHit.rigidbody
attackDir2.x !=0){
//apply damage force to the ragdoll rigidbody hit by the sphere cast (can be any body part)
rayHit.rigidbody.AddForce(attackDir2 * 50.0f, ForceMode.Impulse);
}else{//apply damage force to NPC ragdoll if being damaged by an explosive object or other damage source without a specified attack direction
Component[ ] bodies;
bodies = dead.GetComponentsInChildren();
foreach(Rigidbody body in bodies) {
if(body.transform.name == “Chest”){//only apply damage force to the chest of the ragdoll if damage is from non-player source
//calculate direction to apply damage force to ragdoll
body.AddForce((myTransform.position - attackerPos2).normalized * 30.0f, ForceMode.Impulse);
}
}
}
//initialize the RemoveBody.cs script attached to the NPC ragdoll
if(dead.GetComponent()){
if(removeBody){
dead.GetComponent().enabled = true;
dead.GetComponent().bodyStayTime = bodyStayTime;//pass bodyStayTime to RemoveBody.cs script
}else{
dead.GetComponent().enabled = false;
}
}
Destroy(transform.gameObject);
}
}
static void CopyTransformsRecurse ( Transform src , Transform dst ){
dst.position = src.position;
dst.rotation = src.rotation;
foreach(Transform child in dst) {
// Match the transform with the same name
Transform curSrc = src.Find(child.name);
if (curSrc)
CopyTransformsRecurse(curSrc, child);
}
}
}
If someone is nice enough to make a script for Zombie/barrier delete i would ask if you make the barrier delete script customizable…for example
i have my barrier named “fallen log” so if i take the script and place it on the object. it would let me customize how much it costs to destroy it. (this is an extra thing but if its possible could you make text appear when you look at the log displaying its price.)
Again if this is too much to ask i would be fine if someone could show me how to do it :3
I’m mostly in need for the first script. so if you don’t feel like you want to do the other script that fine i would very appreciate it XD thanks a bunch