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 BrendanFarrell · Nov 11, 2013 at 04:01 AM · error messagejumpingcontrolsacceleration

"No appropriate version" error

Hello! Using the default "thirdpersoncontroller.js" script that's packaged with Unity, I'm attempting to add a "clamp" to the in-air velocity of the character. I'm very very new to scripting so please bear with me. I've researched this issue and often the solution is changing a capital letter here or there, but trying that for myself has proved fruitless.

I'm getting the error: Assets/Scripts/ThirdPersonController.js(175,28): BCE0023: No appropriate version of 'UnityEngine.Mathf.Clamp' for the argument list '(UnityEngine.Vector3, int, float)' was found.

The lines in question are:

 else
 {// Lock camera while in air
     if (jumping) lockCameraTimer = 0.0;
     if (isMoving)inAirVelocity += targetDirection.normalized * Time.deltaTime * inAirControlAcceleration;
         
     Mathf.Clamp(inAirVelocity, 0, walkSpeed);

The code is all default except for the last line which I added. Any advice or guidance would be greatly appreciated!

Comment
Add comment · Show 2
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 yogee · Nov 11, 2013 at 04:36 AM 0
Share

the argument u used is not in proper manner it required (float/int,float/int,float/int) but u using (vector3,int,float)

avatar image BrendanFarrell · Nov 11, 2013 at 04:52 AM 0
Share

Hi Yogee, thanks for the advice. That makes sense. How would I go about clamping just the X and Z components of a vector3? I don't need to clamp the Y at all, so that may be the issue.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Peter G · Nov 11, 2013 at 04:30 AM

There's two errors. One of which is causing the compiler, and the other of which is just causing broken behavior. You have to assign the output of Mathf.Clamp() to something. inAirVelocity is passed by value so the function does not change the original value.

Then there is the compiler error. The error says that the arguments (everything inside the parentheses) don't match up with the existing definitions of clamp. When you call a function, Unity looks through all known definitions to see if the objects you passed as parameters line up with any of the definitions. Since they didn't, the compiler threw an error. In your case, you tried to pass a Vector3, an int and a float.

Here is the definition that you want.

 static float Clamp(float value, float min, float max);

So here's what you actually want to do.

 inAirVelocity = inAirVelocity.normalized * Mathf.Clamp ( inAirVelocity.magnitude , 0 , walkSpeed);
                                // or     * Mathf.Min( inAirVelocity.magnitude , walkSpeed) since magnitude > 0
Comment
Add comment · Show 4 · 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 BrendanFarrell · Nov 11, 2013 at 04:50 AM 0
Share

Peter G,

Thanks so much for answering my question so quickly, and for explaining the reasoning behind the error! Please excuse my lack of understanding, but I'm not able to get it working.

$$anonymous$$y code is as follows:

if (is$$anonymous$$oving) inAirVelocity += targetDirection.normalized Time.deltaTime inAirControlAcceleration;

         inAirVelocity = inAirVelocity.normalized * $$anonymous$$athf.Clamp( inAirVelocity.magnitude, 0, walkSpeed );
     


Which no longer presents an error. However, when I start the game, I'm presented with the error below, and I'm no longer able to control the acceleration of my character in-air.

$$anonymous$$issing$$anonymous$$ethodException: UnityEngine.$$anonymous$$athf.clamp Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreate$$anonymous$$ethodDispatcher

avatar image BrendanFarrell · Nov 11, 2013 at 05:11 AM 0
Share

Ok, this is weird.

When I look up the above error on Google, it seems that it's usually due to improper capitalization. If that's the case for me, the error is telling me "$$anonymous$$athf.clamp" is bad, because the actual syntax is "$$anonymous$$athf.Clamp" with a capital C... however, the line it's referring to in the script DOES have a capital C.

Please tell me I'm not going crazy haha

avatar image BrendanFarrell · Nov 11, 2013 at 05:27 AM 0
Share

Restarted Unity, which seemed to help it realize that that uppercase C was in fact uppercase.

Thanks everyone for the help!!!

avatar image Peter G · Nov 11, 2013 at 05:33 AM 0
Share

Hmmm, that's odd. But restarting did fix the error?

avatar image
0

Answer by BrendanFarrell · Nov 11, 2013 at 06:39 AM

Yeah. Oddly, I've had the same error with HTML/CSS, as well as renaming files in Windows. For example, if you have a file named "Photos of me" in Windows, and attempt to change the name to "Photos of Me", when you hit enter, the file will "update" but its name will still be "Photos of me". The workaround is to rename is to something completely different, and then re-rename it to the old name, but with proper capitalization.

I tried doing that in the unity script, changing "Mathf.Clamp" to "Mathf.somethingridiculous", and then back to Mathf.Clamp, but no luck. Restarting Unity seemed to fix it. Sometimes Windows handles character changes between upper/lowercase in a weird way, I guess.

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

18 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 avatar image avatar image

Related Questions

How do i make jumps follow through with rigidbody2D.addforce? 1 Answer

Jumping while moving 1 Answer

Spaceship Control Help 2 Answers

How do I script Street Fighter style movement? 1 Answer

Why when i press space button nothing was happened 0 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