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
-1
Question by goosoodude · Jul 23, 2011 at 01:23 AM · errorsyntax-erroruce0001

CharacterDamage script semi colon error.

 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;
     
 }
         
 function (detonate)
     // Destroy ourselves
     Destroy(gameObject):
     
     // Play a dying audio clip
     (dieSound)
         }AudioSource.Pl;ayClipAtPoin (dieSound); transform.position;
 
     // Replace ourselves with the dead body
     if (deadReplacement) {
         var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
         
         // Copy position & 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);
     }
 }

 

error Assets/WeaponScripts/CharacterDamage.js(23,18): UCE0001: ';' expected. Insert a semicolon at the end.

I am having trouble. I know what I have to do but I'm not getting what to do. As you can see, there is a semicolon at the end of the line!

Comment
Add comment · Show 19
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 Blankzz · Jul 23, 2011 at 01:27 AM 0
Share

Format your code please. Its too hard to read.

avatar image goosoodude · Jul 23, 2011 at 01:28 AM 0
Share

um, what?

avatar image goosoodude · Jul 23, 2011 at 01:29 AM 0
Share

i mean how?

avatar image Blankzz · Jul 23, 2011 at 01:32 AM 0
Share

highlight the code and press the 101010 button.

avatar image goosoodude · Jul 23, 2011 at 01:35 AM 0
Share

in what the javascript editor or this!

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by aldonaletto · Jul 23, 2011 at 02:48 AM

Boy, you've made a big mess in the middle of the script (the AudioSource.PlayClipAtPoint is completely messed). I think this will work:

var hitPoints = 100.0; // this is the health; when

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

 hitPoints -= damage;  // subtract damage from health
 if (hitPoints <= 0) {  // if health <= 0 the object goes to the grave:
     // Destroy ourselves 
     Destroy(gameObject);
     // Play a dying audio clip
     AudioSource.PlayClipAtPoint(dieSound, transform.position);
     // Replace ourselves with the dead body
     if (deadReplacement) {
         var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
         // Copy position & 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 suppose this is the FPS Tutorial ApplyDamage function. When this object receives the message "ApplyDamage", this routine is called. It subtracts the damage value from the object's "health" (variable hitPoints). When the health become zero or less, the object "dies": it plays its dieSound (if any) and if a dead replacement object was defined, it clones its children to the dead object before suiciding. The dead object is the dead version of the original one - burned, blasted, wrecked etc.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Insert a semicolon error 1 Answer

doing force and spin on a gameobject when clicking on plane. 2 Answers

Scripting error: ';' expected. Insert a semicolon at the end. 2 Answers

Using JavaScript and C# inside one script 2 Answers

UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers


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