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 Jaspb97 · Dec 19, 2012 at 03:46 PM · scipt

Problem'' not compatible with the argument list '(String)'.''

this is the scipt: how to fix ?

function Update() {
var aniPlay = GetComponent ( "aniSprite" ); //aniPlay.aniSprite (16, 16, 0, 0, 16, 12 ); var controller : CharacterController = GetComponent(CharacterController);

 if (controller.isGrounded) 
 {
     jumpEnable       = false;
     runJumpEnable    = false;
     crouchJumpEnable = false;
     
     velocity= Vector3(Input.GetAxis("Horizontal"), 0,0 );
     
     if ( velocity.x  == 0 && moveDirection == 1 )        
     {
        aniPlay.aniSprite  (16, 16, 0, 0, 16, 12 );       
     }
     if ( velocity.x  == 0 && moveDirection == 0)         
     {
        aniPlay.aniSprite  (16, 16, 0, 1, 16, 12 );       
     }  
     if ( velocity.x < 0 )                                 
     {
        velocity *= walkSpeed;
        aniPlay.aniSprite  ( 16, 16, 0, 3, 10, 15 );
     }
     if ( velocity.x > 0 )
     {
        velocity *= walkSpeed;
        aniPlay.aniSprite  ( 16, 16, 0, 2, 10, 15 );      
     }
     if (velocity.x < 0 && Input.GetButton ( "Fire1" ) )
     { 
        velocity *= runSpeed;  
        aniPlay.aniSprite  ( 16, 16, 0, 5, 16, 24 );   
     }
     if (velocity.x > 0 && Input.GetButton ( "Fire1" ) )
     { 
        velocity *= runSpeed; 
         aniPlay.aniSprite  ( 16, 16, 0, 4, 16, 24 );  
     }
     
     
     if ( velocity.x == 0 && Input.GetAxis ( "Vertical" ) < 0)
     {
           if ( moveDirection == 0 )
           {     
               velocity.x = 0;  
               aniPlay.aniSprite  ( 16, 16, 0, 9, 16, 24 ); 
           }
           if ( moveDirection == 1 )
           {
               velocity.x = 0;
               aniPlay.aniSprite  ( 16, 16, 0, 8, 16, 24 );
           }
     }
     if ( Input.GetButtonDown ( "Jump" ) && ( !Input.GetButton ( "Fire1" ) ||Input.GetButton ( "Fire1") && velocity.x == 0 ) && Input.GetAxis ( "Vertical" ) >= 0 )
     {
         velocity.y = walkJump;
         jumpEnable = true;
     }
     if ( Input.GetButtonDown ( "Jump" ) && Input.GetButton ( "Fire1" ) && velocity.x !=0 )
     {
         velocity.y = runJump;
         runJumpEnable = true;
     }
     if ( Input.GetButtonDown ( "Jump" ) && velocity.x == 0 && Input.GetAxis ( "Vertical" ) < 0 )
     {
         velocity.y = crouchJump; 
         crouchJumpEnable = true;
     }
 }
 if ( !controller.isGrounded )
 {
    if ( Input.GetMouseButtonUp ( "Jump" ) )   // #ERROR
    {
       velocity.y = velocity.y - fallSpeed;
    }
   
    velocity.x = Input.GetAxis ( "Horizontal" );
    velocity.x *= walkSpeed;
  }
  if ( velocity.x < 0 ) 
  {
      moveDirection = 0;  
  }                  
  if ( velocity.x > 0 )
  {
      moveDirection = 1;
  }   
  velocity.y -= gravity * Time.deltaTime;
  controller.Move ( velocity* Time.deltaTime );

}

Comment
Add comment · Show 5
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 Landern · Dec 19, 2012 at 03:55 PM 0
Share

You should actually post the complete exception/error, you could post the relevant script/code that include the lines it is referencing.

avatar image Jaspb97 · Dec 19, 2012 at 04:53 PM 0
Share

and how do I send? and to whom?

avatar image Eric5h5 · Dec 19, 2012 at 07:22 PM 1
Share

You post it here. Don't say "there is an error", say which line specifically has the error, ins$$anonymous$$d of expecting people to hunt it down.

avatar image Dave-Carlile · Dec 19, 2012 at 08:06 PM 0
Share

In all fairness, he did mark the error line with a comment. But, it was hard to spot and definitely not the most helpful way of communicating the problem.

avatar image Eric5h5 · Dec 19, 2012 at 09:10 PM 0
Share

Ah, so he did. I scanned the code looking for a comment originally, but didn't see it.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Dave-Carlile · Dec 19, 2012 at 04:56 PM

If you look at the documentation for Input.GetMouseButtonUp, it doesn't take a string as a parameter, but a button index.

Comment
Add comment · Show 2 · 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 shigidaMark · Dec 19, 2012 at 09:30 PM 0
Share

This is correct.

@Jaspb97 Input.Get$$anonymous$$ouseButtonUp(0) will return true the same frame the left mouse button was let up.

Input.Get$$anonymous$$ouseButton(0) will return true EVERY frame the left mouse button is DOWN and false EVERY frame the left mouse button is up.

Alternatively you could use Input.GetAxis("Fire1") as the second method (returns true every frame the left mouse button is down, and false while up).

avatar image Jaspb97 · Dec 19, 2012 at 11:26 PM 0
Share

thnx sooooooooo and soooo and ssooooo muchhhhh!!!!!!!!!!! ;)

avatar image
0

Answer by Next Beat Games · Dec 19, 2012 at 07:02 PM

a couple ways to improve your methodology: make aniPlay & controller public and attach the objects in the inspector at design time instead of getting the component during runtime. This works only when you know when the assignment wont be dynamically chosen at run time.

also, whenever you are using the equality operator (the ==), place the constant to the left of the operator instead of on the right. that way, if you accidentally use assignment operator (=) instead of equality operator(==) you will get a compiler error instead of a logical error. eliminates bug tracking.

Eg. instead of if (velocity.x == 0), use if (0 == velocity.x)

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 Eric5h5 · Dec 19, 2012 at 07:23 PM 0
Share

Actually you get an error if you try to use = ins$$anonymous$$d of == anyway, so the order isn't relevant.

avatar image Next Beat Games · Dec 19, 2012 at 09:09 PM 0
Share

youre right. my bad

avatar image Jaspb97 · Dec 19, 2012 at 09:12 PM 0
Share

and then someone writes the script right?

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

14 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

Related Questions

JavaScript Grid Array Size 0 Answers

UI Masking a GameObject 2 Answers

Null Reference Exception upon entering vehicle 1 Answer

Disable item after 10 shots. 2 Answers

Select and deselect in Editor via C# 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