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 /
This question was closed Jun 27, 2012 at 01:30 AM by Chris12345 for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Chris12345 · Jun 26, 2012 at 11:16 PM ·

How can i trigger a script by collision with a box?

How can i trigger a script by collision with a box? I have a box collider on a object and a script on another object, how can i activate the script using the box Collider ?

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 tomekkie2 · Jun 26, 2012 at 11:40 PM 0
Share

You have to make the script named - say - Play, attach that to the other GameObject. Then create a function celebrate() inside the Play and invoke that.

avatar image Wolfram · Jun 27, 2012 at 05:21 PM 0
Share

For reference, since I just stumbled upon it:

http://answers.unity3d.com/questions/7555/how-do-i-call-a-function-in-another-gameobjects-sc.html

http://docs.unity3d.com/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Wolfram · Jun 26, 2012 at 11:38 PM

Hm? It is not clear to me what you are trying to do exactly. You want to access a script that is attached to the GameObject you assigned to "other"? Then you can use something like this:

 other.GetComponent(PutTheNameOfYourScriptHere).ThisIsAFunctionInThatScript();

Note you declared "other" as being a GameObject, so other.Play("celebrate"); shouldn't work, since a GameObject does not have a function "Play" - it shouldn't even compile. If you're trying to start an animation named "celebrate", use other.animation.Play("celebrate"); instead.

Comment
Add comment · Show 4 · 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 Chris12345 · Jun 27, 2012 at 12:14 AM 0
Share

what is this .ThisIsAFunctionInThatScript(); and what do i do?

avatar image Wolfram · Jun 27, 2012 at 12:40 AM 0
Share

It's an example. Do you have a script attached to "other"? What's it called? Which function do you want to call?

If the answer to any of this is "no" or "I don't know", please explain what exactly you are trying to do.

avatar image Chris12345 · Jun 27, 2012 at 12:57 AM 0
Share

Yes the script is on other.Shoot1. i want to call an entire script on a different object.

avatar image Wolfram · Jun 27, 2012 at 01:34 AM 0
Share

You can not "call an entire script", only functions in that script. Please try to explain what you want to do in other (and more) words.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

C# Scripts don't work in Unity 3.5 any idea why? 1 Answer

Unity Scripts Can be stolen?! 1 Answer

How do I not use a script? 2 Answers

How to get an NPC to wander around 3 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