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
1
Question by Cookied8 · May 20, 2012 at 12:17 PM · animationtriggers

Activate Trigger HELP

I am following this tutorial >>>>> (http://www.youtube.com/watch?v=Dbr-AoG5plk)

Around half way through, he goes to choose an 'Activate Trigger' script, but I cannot seem to find it anywhere. Does anyone know what script he is using? Maybe a link?

Thanks.

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
1

Answer by aldonaletto · May 20, 2012 at 01:34 PM

ActivateTrigger.cs is part of the Scripts package, and should appear in the Component/Scripts menu. You can either import the Scripts package (Assets/Import Package...) or copy the full script from below:

using UnityEngine;

public class ActivateTrigger : MonoBehaviour { public enum Mode { Trigger = 0, // Just broadcast the action on to the target Replace = 1, // replace target with source Activate = 2, // Activate the target GameObject Enable = 3, // Enable a component Animate = 4, // Start animation on target Deactivate= 5 // Decativate target GameObject }

 /// The action to accomplish
 public Mode action = Mode.Activate;

 /// The game object to affect. If none, the trigger work on this game object
 public Object target;
 public GameObject source;
 public int triggerCount = 1;///
 public bool repeatTrigger = false;
 
 void DoActivateTrigger () {
     triggerCount--;

     if (triggerCount == 0 || repeatTrigger) {
         Object currentTarget = target != null ? target : gameObject;
         Behaviour targetBehaviour = currentTarget as Behaviour;
         GameObject targetGameObject = currentTarget as GameObject;
         if (targetBehaviour != null)
             targetGameObject = targetBehaviour.gameObject;
     
         switch (action) {
             case Mode.Trigger:
                 targetGameObject.BroadcastMessage ("DoActivateTrigger");
                 break;
             case Mode.Replace:
                 if (source != null) {
                     Object.Instantiate (source, targetGameObject.transform.position, targetGameObject.transform.rotation);
                     DestroyObject (targetGameObject);
                 }
                 break;
             case Mode.Activate:
                 targetGameObject.active = true;
                 break;
             case Mode.Enable:
                 if (targetBehaviour != null)
                     targetBehaviour.enabled = true;
                 break;    
             case Mode.Animate:
                 targetGameObject.animation.Play ();
                 break;    
             case Mode.Deactivate:
                 targetGameObject.active = false;
                 break;
         }
     }
 }

 void OnTriggerEnter (Collider other) {
     DoActivateTrigger ();
 }

}

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 Linmst · Apr 13, 2013 at 10:44 AM 0
Share

Hey, dude.. would you please tell me why this default script goes wrong when I export my game? Thanks!

It's just showed me "Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(43,58): warning CS0618: UnityEngine.GameObject.active' is obsolete: GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.' "

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Light animation and Main Menu animation at same time from 1 trigger 0 Answers

Need help with Animations 1 Answer

Looping animation while key down 1 Answer

How do I activate an animation when a gameobject enter the Collider of the other animated object 2 Answers

Trigger plus Key Activation. 0 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