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
0
Question by carlqwe · Mar 22, 2016 at 04:38 PM · error

GettIng Error when trying to set a script to false

Hello, i have a script were im trying to make osme kind of pausemenu. Everything works but i really want it so the movement stops working when the game is paused. But when i try to set my movementscript to false, i get an error. "The name 'Movement' does not denote a valid type ('not found')."

Clearly it cant find the script, can soeone help me and tell me why it cant find it?

Thanks (:

 #pragma strict
 
 var PauseMenu : GameObject;
 var mouseLook : Movement;
 
 function Start ()
 {
     Screen.lockCursor =true;
 }
 
 function Update ()
 {
     if(Input.GetKeyDown(KeyCode.Escape))
     {
         var mouseLook = GameObject.Find("Player").GetComponent.<Movement>();
         
         //HERE IS THE PROBLEM
         mouseLook.enabled = !mouseLook.enabled; 
         //HERE IS THE PROBLEM
         Time.timeScale = 0.0;
         PauseMenu.SetActive (true);
         Cursor.visible = true;
     }
 }
 
 function BUTTONMainMenu ()
 {
     Application.LoadLevel("MainmenuScene");
 }
 
 function BUTTONExit ()
 {
     Application.Quit();
 }
 
 function BUTTONRETURN ()
 {
     Time.timeScale = 1.0;
     PauseMenu.SetActive (false);
     Cursor.visible = false;
 }

Comment
Add comment · Show 3
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 TreyH · Mar 22, 2016 at 05:57 PM 0
Share

We don't know anything about your project structure. Is everything named correctly? Is it in an Editor folder? Is the class name within that script correctly matching the file name?

avatar image meat5000 ♦ · Mar 22, 2016 at 06:38 PM 0
Share

Check that the $$anonymous$$ovement file exists and is placed on to the Player object.

avatar image tanoshimi · Mar 22, 2016 at 06:49 PM 0
Share

Please post the content of your $$anonymous$$ovement.js file.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by phil_me_up · Mar 22, 2016 at 08:12 PM

This isn't valid

 var mouseLook = GameObject.Find("Player").GetComponent.<Movement>();

You probably want the below. I never use Javascript so may have got the syntax wrong.

 var mouseLook = GameObject.Find("Player").GetComponent("Movement");

Check the docs for more info: http://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html

Comment
Add comment · Show 1 · 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 meat5000 ♦ · Mar 25, 2016 at 10:40 AM 0
Share

Incorrect! TreyH said exactly the same thing a few days ago. That syntax is perfectly valid and is the JS equivalent of

 GetComponent<$$anonymous$$ovement>();  // C#

 GetComponent.<$$anonymous$$ovement>(); // In JS you add the extra dot
avatar image
0

Answer by meat5000 · Mar 25, 2016 at 10:47 AM

The error occurs when the file "Movement" does not exist!

It is not even saying it cant find the component on the player. Its saying its not a valid Type. This means the class does not exist. This is easily proven by creating a new file called Movement.js. The error will go away straight away.

If you believe it does exist, open the Movement.js file and check that the Class name matches the filename exactly (although this may show a different error).

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

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

Related Questions

Troubleshooting the spawn mechanic in a puzzle game 1 Answer

Error in android manifest. Text as if encrypted. XML fails validation in the browser. 0 Answers

True False What am I doing wrong. 1 Answer

First time open error android game 0 Answers

"function DoRoll (Point, Axis, Angle, Duration)" Does Not Work on Android. Any reasons? 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