Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ChompIV · Feb 07, 2017 at 05:30 PM · 3denemydamagezombieshp

How to make enemys do damage and you dying etc

So I have a zombie arcade game in 3d, zombies can die, i do dmage, they fallow me, alls good. I Besides I need the zeds to be able to kill me as in 4 hits to me ends the game and switches to a GAME OVER scene. doesnt sound too complicated but ive been stuggling with this for the past 2 weeks. Also I would like if on each of the 4 hits blood goes on the screen and it gets redder (like in cod haha). Thanks anyone who helps! Heres my EnemyController Script:

     using UnityEngine;
     using System.Collections;
     using UnityEngine.AI;
     
     public class EnemyController : MonoBehaviour {
         NavMeshAgent nav;
         Transform player;
         Animator Controller;
     
         // Use this for initialization
         void Awake () {
             nav = GetComponent <NavMeshAgent> ();
             player = GameObject.FindGameObjectWithTag ("Player").transform;
             Controller = GetComponentInParent<Animator> ();
         }
     
         // Update is called once per frame
         void Update () {
             nav.SetDestination (player.position);
             Controller.SetFloat ("speed", Mathf.Abs (nav.velocity.x + nav.velocity.z));
         }
     }
 

HERES MY GAME MANAGMENT SCRIPT IF YOU MAY NEED IT?

     using System.Collections;
     using UnityEngine;
     
     public class GameManagment : MonoBehaviour {
         public int round = 1;
         int zombiesInRound = 10000000;
         int zombiesSpawnedInRound = 0;
         float zombieSpawnTimer = 0;
         public Transform[] zombieSpawnPoints;
         public GameObject zombieEnemy;
     
         // Use this for initialization
         void Start () {
     
         }
     
         // Update is called once per frame
         void Update () {
             if (zombiesSpawnedInRound < zombiesInRound)
             {
                 if (zombieSpawnTimer > 2.1)
                 {
                     SpawnZombie ();
                     zombieSpawnTimer = 0;
                 }
                 else
                 {
                     zombieSpawnTimer += Time.deltaTime;
                 }
             }
         }
     
         void SpawnZombie()
         {
             Vector3 randomSpawnPoint = zombieSpawnPoints [Random.Range (0, zombieSpawnPoints.Length)].position;
             Instantiate(zombieEnemy, randomSpawnPoint, Quaternion.identity);
             zombiesSpawnedInRound++;
         }
     }



Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PizzaPie · Feb 08, 2017 at 01:26 PM 0
Share

Survival Shooter in Unity Learn section covers the subject of health and attack in a basic/decent way start from there. Anyway the logic behind the system is to have a script that holds a Health field on all entities (zombies/player) and you gonna need an attack method for player and one for the zombies. The Attack() should figures the target and reduce a porsion of the health from the target. For the zombies thats easy cause only the player is the target, but for the player it is a bit more tricky. Also you need a way to trigger the attack method, for the player through an Input, but for the zombies a more automated way is needed probably through the distance of the target. Lastly for the bloody screne it s quite easy you need to link the health of the player to an UI.image and change it depending on that(i think it is covered in the tutorial). Cheers.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Pitiedowl · Feb 08, 2017 at 09:07 AM

look up speed tutor on youtube he does some of these things and as for health and such its very difficult good luck

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Canduct and movement of an enemy 0 Answers

Damage on prefab collision? 0 Answers

Enemy Damage to Player 0 Answers

Damage enemy cooldown 2 Answers

Player attacks once but the enemy takes double damages! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges