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 ShinyTaco · Jan 03, 2013 at 10:22 AM · playerdisablecontrolsenable

Recommended way to delay controls momentarily?

Hello all,

I have a camera animation that lasts a few seconds at the beginning of my game. However, the player can still move while the camera is animation is being played.

What's the best way to delay the player controls from being enabled?

Thanks in advance.

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 Fattie · Jan 03, 2013 at 12:57 PM 0
Share

a very simple command you must master is Invoke().

so it's just something like Invoke( "turnOnControls", 2.5 );

read about it at unityGE$$anonymous$$S.com

avatar image ShinyTaco · Jan 04, 2013 at 05:40 AM 0
Share

Thanks for the help Fattie.

I made a function called myTestInvoke and used Debug.Log to see if it works. I tried different amounts of time in seconds to confirm that it works and it does. Great!

However, the problem is the controls are in the Update function.

How do you Invoke the player controls when they are in the update function?

Thanks.

2 Replies

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

Answer by Dave-Carlile · Jan 04, 2013 at 12:57 PM

Use a boolean to control whether or not input is enabled. You can set the boolean value in various ways. One way is to initialize it to false, then set it to true once the camera animation is complete.

You're checking for input in the Update function. If the boolean is false, meaning input is not enabled, then skip the input checks. If it's true, meaning the input is enabled, then do the input checks.

 bool controlsEnabled = false;
 
 
 void CheckInput()
 {
   // TODO : do your input checking here
 }
 
 
 void Update()
 {
   if (controlsEnabled)
   {
     CheckInput();
   }
 }
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 ShinyTaco · Mar 27, 2013 at 02:37 PM 0
Share

Got it, thanks.

avatar image
1

Answer by Piflik · Jan 03, 2013 at 10:48 AM

Create a boolean variable that you set to false if the camera is animated and only allow movement when this boolean is true.

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 ShinyTaco · Jan 04, 2013 at 05:44 AM 0
Share

Hi Philipp,

Thanks for the help.

Let's say I had a boolean called isCameraAnimated. How do you reference that to the actual camera being animated? How does the boolean know that the camera is animated?

Thanks again.

avatar image Piflik · Jan 04, 2013 at 12:05 PM 0
Share

You would control that boolean whenever you animate the camera. If you only have one camera, you could make that variable static. Declare it in the same script that controls the camera and if it is animated set it to false (or true). After the animation is finished reset it again.

You can test if a specific animation is playing with Animation.IsPlaying("AnimationName"), Or you use a coroutine to play an AnimationClip and yield for the AnimationClip's length.

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

11 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

Related Questions

Can CompositeCollider2D not be disabled? 1 Answer

Bool activate/de-activate on timer C# 1 Answer

Why my player settings is disabled? Unity 5.6.1 3 Answers

Enable and Disable scripts 1 Answer

Enabling and Disabling Shurken Particles 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