• 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 niyativirmani13 · Jan 29, 2021 at 07:31 AM · space

How to display an object for just few seconds repeatedly in a scene?

I am making a VR video on the working of GNSS Satellite. My scene has an Earth and a satellite which is orbiting around the Earth. I want to show signal transmission from and to the satellite with the help of arrows. But these arrows ( one pointing from satellite to earth and other pointing from earth to satellite) should be visible only for the amount of time the satellite crosses their position. How can I do that? Kindly help please

Comment
Add comment
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

2 Replies

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

Answer by Llama_w_2Ls · Jan 30, 2021 at 12:31 PM

A simpler way is using a coroutine. For example:

 public float TimeAmount;
 public GameObject arrow;
 
 void Start()
 {
      StartCoroutine(ToggleArrow(TimeAmount));
 }
 
 IEnumerator ToggleArrow(float delay)
 {
      while (true)
      {
           yield return new WaitForSeconds(delay);
           arrow.SetActive(true);
 
           yield return new WaitForSeconds(delay);
           arrow.SetActive(false);
      }
 }

@niyativirmani13

Comment
Add comment · Show 7 · 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 niyativirmani13 · Feb 01, 2021 at 10:57 AM 0
Share

Heyy, thanks for this answer.. with this my arrow gets disappeared but how do I show it again? Suppose for now I have kept the time limit as 2 seconds. So it does go away in 2 seconds but I want it to come again and then go again and so on. It should blink

avatar image Llama_w_2Ls niyativirmani13 · Feb 01, 2021 at 11:12 AM 0
Share

I thought that's what my script does. It waits two seconds, sets the arrow object to active, waits two seconds, sets it to inactive, and repeats infinitely. Possibly you implemented it incorrectly?

avatar image niyativirmani13 Llama_w_2Ls · Feb 01, 2021 at 12:11 PM 0
Share

I dont find it implementing incorrectly.. my arrow just got disappeared after 2 seconds (which I mentioned) but it didnt re appear again

Show more comments
avatar image
1

Answer by MathijnG · Jan 29, 2021 at 03:45 PM

For me normally the easiest way would be to use Time.deltaTime. See here:

 float TimeAmount;
 float currentTime;
 GameObject arrow;
 
 private void Start()
 {
   currentTime = TimeAmount;
 }
 
 private void Update()
 {
   currentTime -= Time.DeltaTime;
 
   if (currentTime <= 0)
   {
     if (arrow.activeSelf)
     {
       arrow.SetActive(false);
     }
     else
     {
       arrow.SetActive(true);
     }
     currentTime = TimeAmount;
   }
 }
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 niyativirmani13 · Feb 01, 2021 at 12:32 PM 0
Share

How do I set the time amount?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

111 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 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 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

Space.World and Space.Self don't work 1 Answer

iTween MoveAdd world coordinates Simple 2 Answers

Point gravity implementation lacks precision 2 Answers

Freelance Space Sim Style Controls 0 Answers

How to make first-person work in zero-G with planets? 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