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
0
Question by hotozi · Nov 04, 2012 at 04:12 PM · gameobjectphysicstrigger

My script doesn work Trigger Problem!! HELP!!

tell me what in my script is not good...beause the trigger doens work...

var Detect=false;

var AnyTag=false;

function Update () {}

function OnTriggerStay(Hit:Collider)

{

if(Hit.gameObject&&AnyTag){Detect=true;}

if(Hit.gameObject.tag=="terrain"){Detect=true;}

}

function OnTriggerExit(){Detect=false;}

Comment
Add comment · Show 1
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 mhughson · Nov 04, 2012 at 08:14 PM 0
Share

What part of your script doesn't work? Does it compile? If so, what behaviour are you seeing that seems wrong? Have you attempted to put a break point in the problem code to see if it is being called and then check what code paths are being executed?

3 Replies

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

Answer by magnussolidus · Nov 05, 2012 at 01:13 PM

Did you guys forget that you need to have a rigid body attached to one of the game objects that are colliding to activate the trigger? Check if this isn't the problem! I forget the link to the collision matrix, but try to find something about triggers collision on documentation and you will know about what I'm talking about.

Note: Will be better apply the rigid body to the game object that is moving, not the static one. Please check the documentation for further information.

Hope it helps =)

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 hotozi · Nov 05, 2012 at 11:56 PM 0
Share

because...i used an other sript that have the same function but different gameobject...and those gameobject are rigidbody but not the transform and its working...so if i do understand...that mean the transform need to be a rigidbody or the target need to be riight? thats my analyse thesis?

avatar image hotozi · Nov 06, 2012 at 12:15 AM 1
Share

YO...YO..Yo dawg!!! for real...u saved my life...you just make me understand something that can solve my other problems that i had no answers....so yo for real THAN$$anonymous$$S YOU!!...Yo bro i guest u cant understand...but got dam son....i gotta thanks u again!!

avatar image
0

Answer by Montraydavis · Nov 04, 2012 at 07:53 PM

Why is the AnyTag in the if ? Is that meant to be there because I see no other references . . . O.o

Try this:

 var Detect : boolean = false ;
 
 function Update ( ){
 
 }
 
 function OnTriggerStay ( collision : Collider )
 {
    if ( collider.gameObject.tag == "terrain" )
    {
       Detect = true ;
    }
 }
 
 function OnTriggerExit ( collision : Collider )
 {
    if ( collider.gameObject.tag == "terrain" )
    {
       Detect = false ;
    }
 }
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 hotozi · Nov 05, 2012 at 12:56 PM 0
Share

still not working!!

avatar image Montraydavis · Nov 05, 2012 at 05:14 PM 0
Share

Do you have Rigidbodies and Box Colliders enabled? And what do you mean "still not working" . I still don't understand "what doesn't work" . . . Are you falling through the floor ? Walking through walls? Partially falling through floor? etc?

avatar image
0

Answer by magnussolidus · Nov 06, 2012 at 12:04 AM

At least one of the game objects need to have a rigid body component attached to it if you wanna Unity to detect the trigger.

Please, take a loot at this: http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

In the end you have the collision matrix. =)

Can you post the code so I can take a look of it and try to find the problem?

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

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

12 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

Related Questions

Multiple Cars not working 1 Answer

My script doesnt respond what i wrote HELP!!! 0 Answers

Message sender...how to know who send the message 1 Answer

Array Help GameObject Length Inventory 1 Answer

Unity3D Timer. 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