• 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 TheTretheway · Jul 28, 2013 at 09:19 AM ·

What Am I Doing Wrong?

Hey, thanks for helping... I'm having a few basic problems, and I can't seem to find anything on the internet about it.

I have a script here, in JS, which is using some things I found on the internet, and others from previous (working) scripts.

I'm getting three errors: BCE0043: (16,17) Unexpected token: if BCE0043: (16,21) Unexpected token: Win BCE0044: (18,45) expecting : , found =

Script:

 #pragma strict
 
 var score : int = 10;
 var health : int = 15;
 var Win : int;
 Win = (Random.Range(1, 2));
 var oldscore;
 var oldhealth;
 
 function Update ()
 {
 if (Input.GetButtonDown("Fire2"))
     oldscore = Melee.score;
     oldhealth = Melee.health;
     {
         if (Win = 1);
             {
                 Melee.score = oldscore + score;
             }
                 
         if Win = 2;
             {
                 if ((Melee.health + health) = <=100)
                     {
                         Melee.health = oldhealth + health;
                     }
                     
                 else
                     {
                     null;
                     }
     Destroy (gameObject);
             
             }
             
 }
 }

Thanks for your help!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Lovrenc · Jul 28, 2013 at 09:20 AM

 if (Win = 1);

Should be

  if (Win == 1)



 if Win = 2;

Should be

 if (Win == 2)

etc.

 if ((Melee.health + health)  <= 100)
Comment
Add comment · Show 3 · 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
avatar image TheTretheway · Jul 28, 2013 at 09:47 AM 0
Share

Thanks for the help...howver now I get these problems...

alt text

Script: #pragma strict

 var score : int = 10;
 var health : int = 15;
 var Win : int;
 Win = (Random.Range(1, 2));
 var oldscore;
 var oldhealth;
 
 function Update ()
 {
 if (Input.GetButtonDown("Fire2"))
     oldscore = $$anonymous$$elee.score;
     oldhealth = $$anonymous$$elee.health;
     {
         if (Win == 1)
             {
                 $$anonymous$$elee.score == oldscore + score;
             }
                 
         if (Win == 2)
             {
                 if (($$anonymous$$elee.health + health) <=100)
                     {
                         $$anonymous$$elee.health = oldhealth + health;
                     }
                     
                 else
                     {
                     null;
                     }
     Destroy (gameObject);
             
             }
             
 }
 }
untitled-1.jpg (54.1 kB)
avatar image gregzo · Jul 28, 2013 at 09:52 AM 1
Share

Please do a few scripting tutorials, this code is full of mistakes and improperly formatted. You cannot come here everytime you need to write a script and have it done for you.

avatar image TheTretheway · Jul 28, 2013 at 10:51 AM 0
Share

Sorry, I was a bit annoyed when I posted the second script. Believe it or not, I have done a few tutorials...a lot of the stuff Unity was confused about was based off a few errors I had made, which it then suggested solutions for...simply put having done all the solutions Unity had suggested I didn't understand the code any more. I've now rewritten and I think I have it done. Thanks

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Animation + Scripting = I Don't Understand (Help) 0 Answers

Can Someone help me with a script? (2D) 0 Answers

Script suddenly stopped working properly 1 Answer

ERROR unity expected. insert a semicolon at the end 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges