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 IMTRIGGERHAPPY9 · Aug 16, 2011 at 03:54 AM · ontriggerenterontriggerexit

What data is stored in "other"?

in OnTriggerEnter (OTHER : Collider); what data is stored in the other? because for the past little bit i have been using as if it was a gameobject, but it isnt working out. so i would like to know what exactly it is reffering to there?

Comment
Add comment · Show 3
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 IMTRIGGERHAPPY9 · Aug 17, 2011 at 05:56 AM 0
Share

Assets/LookAt.js(9,33): BCE0023: No appropriate version of 'UnityEngine.Transform.LookAt' for the argument list '(UnityEngine.GameObject)' was found.

now its giving me this... which is kinda contridicting its self...

i am so thankful for you help though! i have posted and reposted questions like this for about 3 weeks now and no one could help me... like no one even told me that collider could be extended. so thank you

avatar image aldonaletto · Aug 17, 2011 at 01:06 PM 0
Share

Yeah, I missed that: LookAt can accept a Transform, not a GameObject - just add .transform to the monster variable:

...
if (attackRTriggerStay.targetAquired){
    transform.LookAt(attackRTriggerStay.monster.transform);
}
...
I fixed this in the answer too.
avatar image IMTRIGGERHAPPY9 · Aug 17, 2011 at 05:49 PM 0
Share

!!!!!!!!!!!!!!!!!! you saved me!!! ha ha i am so happy right now!!! i knew while i was working on it it would be something simple that i was overlooking, but i didnt even know that a collider could take that stuff after its been assigned! thank you again

1 Reply

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

Answer by aldonaletto · Aug 16, 2011 at 04:17 AM

A Collider has direct access to the same inherited variables as a Transform or GameObject, like transform, gameObject, rigidbody, collider, name, tag etc. (take a look at the Inherited Variables in Collider to get a complete list).

EDITED: A game object has some basic variables (transform, collider, rigidbody, gameObject) that can be used as references to other variables of the same object. If you have transform, but want to get the gameObject reference, you can use transform.gameObject;

var invaderGameObject: GameObject; var invaderTransform: Transform;

function OnTriggerEnter(other:Collider){ invaderGameObject = other.gameObject; invaderTransform = other.transform; } EDITED2: The trigger script may declare targetAquired and monster as static variables, and read them in the tower script.
This is the trigger script:

static var targetAquired = false; static var monster: GameObject;

function OnTriggerEnter (other : Collider) { if(other.gameObject.CompareTag ("enemy")){ monster = other.collider.gameObject; targetAquired = true; } }

function OnTriggerExit (other : Collider) { if(other.gameObject.CompareTag ("enemy")){ targetAquired = false; } }

The tower script (below) must read the static variables using the name of the trigger script (what I suppose is attackRTriggerStay.js):

function Update () {
  if (attackRTriggerStay.targetAquired){
    transform.LookAt(attackRTriggerStay.monster.transform);
  }
}
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 IMTRIGGERHAPPY9 · Aug 17, 2011 at 12:24 AM 0
Share

so how would i go about accessing that colliders transform? so that i could then use it in the transform.LookAt()?

avatar image aldonaletto · Aug 17, 2011 at 02:26 AM 0
Share

Who do you want to look at who? other look at some object, or the trigger owner to look at owner?

avatar image IMTRIGGERHAPPY9 · Aug 17, 2011 at 02:42 AM 0
Share

want another object that gets info from the trigger owner to look at the trigger causer.... so basically a tower looking at an enemy with an attack radius.

avatar image IMTRIGGERHAPPY9 · Aug 17, 2011 at 02:44 AM 0
Share

but from what i understand looking at this object is next to impossible because it is a collision class. therefore cannot be used as a transform class which makes absolutely no sense to me...

avatar image aldonaletto · Aug 17, 2011 at 04:30 AM 0
Share

It's simple: the collider is one of the basic object variables, and these basic variables can access each other directly - if you have the object's collider, you can get its transform as collider.transform, or its gameObject as collider.gameObject. Take a look at my edited answer.

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Problem using trigger to set gameobjects active 1 Answer

Can someone clarifies OnTriggerEnter, OnTriggerExit and OnTriggerStay for me? (I have image included already) 0 Answers

Deactivate/Activate FPS Movement 0 Answers

OnTriggerEnter works once, OnTriggerExit not at all? 1 Answer

Audio not playing after OnTriggerStay is applied to the scripts (Driving Simulator Project) 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