Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Jdraconus · Apr 25, 2011 at 10:39 PM · fpsenemyfpstutorial

How do I make a FPS Boss?

Hello everybody. I am brand new to programming and am going through the FPS tutorial, but the one thing the tutorial does not teach you is how to make a boss character and how to end the game, once everything is dead you just kinda sit there. Here is the script I was thinking my game over condition should be put into

var hitPoints = 100.0; var deadReplacement : Transform; var dieSound : AudioClip;

function ApplyDamage (damage : float) { // We already have less than 0 hitpoints, maybe we got killed already? if (hitPoints <= 0.0) return;

hitPoints -= damage;
if (hitPoints <= 0.0)
{
    Detonate();
}

}

function Detonate () { // Destroy ourselves Destroy(gameObject);

// Play a dying audio clip if (dieSound) AudioSource.PlayClipAtPoint(dieSound, transform.position);

// Replace ourselves with the dead body if (deadReplacement) { var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);

 // Copy position &amp; rotation from the old hierarchy into the dead replacement
 CopyTransformsRecurse(transform, dead);

}

}

static function CopyTransformsRecurse (src : Transform, dst : Transform) { dst.position = src.position; dst.rotation = src.rotation;

for (var child : Transform in dst) {
    // Match the transform with the same name
    var curSrc = src.Find(child.name);
    if (curSrc)
        CopyTransformsRecurse(curSrc, child);
}

}

I was wondering if that would be the correct spot to put it into and what exactly would i put into it to make the game end? any help on this would be greatly appreciated even a book I could look into to find the answer myself would be great.

Thank you so much for your time

JDraconus

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 Michael 12 · Apr 25, 2011 at 10:49 PM 0
Share

Oooh, that is a good question and one I've been wondering myself... I added this to my favorite questions :D

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by GesterX · Apr 25, 2011 at 11:07 PM

You have a few choices. The simplest is to simply exit the application when you want the game over to happen. You can do this using Application.Quit which you can read about here:

http://unity3d.com/support/documentation/ScriptReference/Application.Quit.html

This has no effect in the editor or in a web player though!

The second and third options is to restart the game by reloading your current scene OR load another scene (such as a menu/level select). You can do this by using Application.LoadLevel. See this:

http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html

Now to check if the game has ended you'll want to tag all enemies and use the following function:

http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html

You just need to use this function and then check the length of the array (in the example in the link you would check if gos.length was 0)

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

No one has followed this question yet.

Related Questions

Making bullet holes in enemies. 1 Answer

fps shooting enemy 1 Answer

I need help creating a ZombieAI for my Walking Dead Game 0 Answers

Why is this script causing a lot of lag? 2 Answers

Head Shot = Instant kill for FPS enemies 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