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 gamegirl1984 · Sep 06, 2015 at 01:24 PM · animationtriggersetactivedisable object

How to use one trigger that will set object active then when hit the 2nd time will deactivate it?

Hello. I have a Scene as follows. (And the TV is ON at start) a TV with a TVON Texture on it already, a TV Remote, A Black quad for TVOFF. An animation on the remote, And a Trigger.

When i hit the trigger, the trigger becomes inactive, the remote animation plays, then after 1 sec. the TVOFF quad becomes active and covers the TV making it look off.

Ok so now the TV went from on to off and played a remote animation. And I can't re hit the trigger. AWESOME! that works.

Now here is where i'm stumped.

So the TV is off. I would like to turn the TV back on again and also play that same remote animation. so now i need to reactivate the trigger to..... 1. How can I do this same thing again with the same trigger BUT make my TVOFF game object become deactive instead of active?? So when i hit the trigger again next time it will turn the TV Back on?? 2. Would an if statement work in here? Seems like it could be pretty easy. Please help.

( I cannot provide a script because i'm using Blox 2 visual scripting.)

However, its very script like so as long as i know what i would need in a script i could incorporate that into blox 2.

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

1 Reply

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

Answer by wibble82 · Sep 06, 2015 at 02:02 PM

The details of your question are a little confusing, so I'll just say how I'd do it.

In my 'OnTriggerEnter' function, I'd have a simple statement like this:

         //check if currently active, and turn it on or off accordingly
         if(mytargetobject.activeSelf)
         {
             mytargetobject.SetActive(false);
         }
         else
         {
             mytargetobject.SetActive(true);
         }
 

i.e. you are asking the 'tv' if it is active. If it is, you deactivate it. If not, you activate it. I'd imagine you can extent this concept into your script somehow?

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 Suddoha · Sep 06, 2015 at 02:17 PM 0
Share

It's even shorter like this:

   target.SetActive(!target.activeInHierarchy);
avatar image gamegirl1984 · Sep 06, 2015 at 03:11 PM 0
Share

O$$anonymous$$G!!! Thank you! I took what you said not thinking I could actually get this to work with Blox 2. And I can't believe it actually is working! I don't even know how this works but it does thanks to you. Now I see blox 2 is even more like actual scripting than i though! You saved me alot of time.

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

29 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

Related Questions

C# - Trigger Animation with Raycasting? 1 Answer

Mecanim Trigger Stays too long true 1 Answer

Starting a 2D animation on a trigger 1 Answer

Possible to stop collider from "popping" through plane when re-centering? 2 Answers

importing exporting Animation help. 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