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 MrSkiz · Jul 17, 2012 at 09:22 AM · triggernormal

Are Triggers not based upon normals?

Hi,

Here's the thing : Imagine a corridor. I want to change the color of each corridor's section I'm walking by to red if I'm walking in one way, but to blue if I'm walking the other way.

I thought to have two simple quads at eache edge of a section, with normals pointing towards each ways so if you walk through a trigger with normal not facing you it won't react. But it seems a 'is trigger' collision mesh doesn't work based upon normals as a mesh collider do. From whatever side I walk through the trigger, it is trigged.

Do you confirm that? Any alternative?

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 Fattie · Jul 17, 2012 at 12:26 PM 0
Share

nice use of "trigged".

3 Replies

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

Answer by MrSkiz · Jul 23, 2012 at 03:06 PM

Ok, I solved the problem, thanks to Fattie's "gate" tips, by playing with two triggers sending custom strings into an array in another global trigger covering the section. I then concatenate (array.join) and, depending the result, I change the corridor section's color.

The A gate triggers (B is the same with "As" changed to "Bs":

function OnTriggerEnter (collisionInfo : Collider) {
 if(collisionInfo.gameObject.tag=="BlueTeam") {
 SendMessageUpwards ("PushSectionArray","BlueA");
    }
    else if(collisionInfo.gameObject.tag=="RedTeam") {
     SendMessageUpwards ("PushSectionArray","RedA");
    }
}

The global section trigger :

var sectionArray = new Array();

function OnTriggerStay () { if (sectionArray.length == 2){ var resultArrayJoin = sectionArray.join("-"); print (resultArrayJoin); if (resultArrayJoin == "BlueA-BlueB"){ SendMessageUpwards ("BlueClaim"); sectionArray.clear(); } else if (resultArrayJoin == "RedB-RedA"){ SendMessageUpwards ("RedClaim"); sectionArray.clear(); } else { sectionArray.clear(); } } }

function OnTriggerExit () { sectionArray.Clear(); }

function PushSectionArray (triggerEcho : String) { sectionArray.push(triggerEcho); }

The Red/blue changer code :

var colorActual : Color; var colorBlue : Color = Color.blue; var colorRed : Color = Color.red; var duration : float = 10.0;

function Start () { renderer.material.color = Color.grey; }

function BlueClaim () { colorActual = renderer.material.GetColor("_Color"); //var lerp : float = duration * Time.DeltaTime; var lerp : float = Time.time / duration; renderer.material.color = Color.Lerp (colorActual, colorBlue, lerp); }

function RedClaim () { var lerp : float = Time.time / duration; renderer.material.color = Color.Lerp (colorActual, colorRed, lerp); }

I just now have to figure how to make my Color.Lerp do a smooth transition. The same code of my Red/BlueClaim functions inserted in an Update() works as intended.

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
avatar image
2

Answer by Meltdown · Jul 17, 2012 at 10:28 AM

Colliders are based on normals, yes, triggers are not.

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
avatar image
0

Answer by MrSkiz · Jul 17, 2012 at 10:40 AM

I think I solved the case : I was assigning a mesh collider as trigger to an empty. So I was only colliding with the trigger.

But by using the quad mesh with transparent texture with it's mesh collider flagged as trigger it works as intended, the trigger responds only when I go through the mesh from the side where its normal is.

Any warnings regarding the use of this trick (if it's one...)?

edit : apparently it doesn't work.

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 Bunny83 · Jul 17, 2012 at 10:58 AM 1
Share

Transparent texture? You can (or should) just remove the renderer of the plane... All you have left is the $$anonymous$$eshCollider with the plane mesh assigned.

How does your mesh look like? is it really plane? There could be tilted triangles. A screenshot of the mesh would help i guess.

avatar image MrSkiz · Jul 17, 2012 at 12:22 PM 0
Share

Yes, it's just a cube from which I removed 5 of the 6 faces. And yes, unticking the renderer part make the object trigger only.

But with further experiments my trick doesn't work. I think I'll have to play with 2 triggers and check in which order they're triggered to find in which way the player is moving.

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

Can't click gameobject when over another trigger? 1 Answer

Normal map appears to be wrong when generated 2 Answers

audio trigger keydown 1 Answer

Get Player to 'Stick' to Surface 0 Answers

Trigger Respawn 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