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 $$anonymous$$ · Jan 07, 2015 at 09:31 AM · animationjavascriptfirst-person-controllerif

Script block animations and other scripts

  #pragma strict
  var wnCanvas : Canvas;
  
  function Update () {
      if (transform.position == Vector3(0, 100, 0))
          (gameObject.Find("fpc").GetComponent("MouseLook") as MonoBehaviour).enabled = false;
          (gameObject.Find("Main Camera").GetComponent("MouseLook") as MonoBehaviour).enabled = false;
          wnCanvas.enabled = true;
          Time.timeScale = 0;   
          Screen.lockCursor = false;
          Screen.showCursor = true;
          GameObject.Find("fpc").audio.volume = 0.5;
          GameObject.Find("fpc").GetComponent(fst_mo).enabled = false;
          GameObject.Find("fpc").GetComponent(slw_mo).enabled = false;
          GameObject.Find("Main Camera").GetComponent(cmr_zm).enabled = false;
          
  }
  

But if I attach him to First Person Controller my animations and scripts doesn´t work. What´s wrong with this script?

Comment
Add comment · Show 4
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 GameVortex · Jan 07, 2015 at 09:35 AM 0
Share

So your issue is that this script disables script and animations on your First Person Controller?

Well that is exactly what is is doing, it is disabling the mouselook controller, the motion controllers, the camera. So apart from being extremely inefficient because it calls Find functions in the Update loop, there is not much else wrong.

Although it will most likely not disable the scripts at all because it is very unlikely that transform.position will ever be exactly equal to Vector3(0, 100, 0).

We might need some more information on what you are trying to achieve to be able to help you better.

avatar image Priyanshu · Jan 07, 2015 at 10:22 AM 1
Share

From what i understand you want to disable components and pause game when player reaches Vector3(0, 100, 0)

If so, put your code below If statement within curly braces. alt text

ans.png (29.5 kB)
avatar image Priyanshu · Jan 07, 2015 at 10:26 AM 1
Share

At the moment your script executes following code when If statement is true because of missing curly braces.

 (gameObject.Find("fpc").GetComponent("$$anonymous$$ouseLook") as $$anonymous$$onoBehaviour).enabled = false;

All other code is executed every frame.

Since you execute Time.timeScale = 0; every frame.Your animations have stopped and so have other objects which depend on time.

avatar image $$anonymous$$ · Jan 07, 2015 at 10:32 AM 0
Share

thank you! it´s working now...

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mangas · Jan 07, 2015 at 12:03 PM

The problem is that Time.timeScale is 0, so your game is basically paused.

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 $$anonymous$$ · Jan 07, 2015 at 12:47 PM 0
Share

no i want it paused...

avatar image
0

Answer by alok-kr-029 · Jan 07, 2015 at 09:36 AM

Time.timeScale = 1;
I am not sure but looks you have changed the time scale to zero

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

FPS game walk animation script help 1 Answer

Make the animation play at the start of the time waited, not the end of it? 1 Answer

Current speed of an object? 5 Answers

How do I get my "dashing" animation to work? 1 Answer

Animation play on input, else play idle animation. 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