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
2
Question by PlatinumSkink · Jan 03, 2011 at 04:07 PM · collisionportalnothing

Why is the code not called?

Hiya. I am doing my first ever unity-project, and I find it excruciatingly much more trouble than Visual Studio or Flash ever was. Enough about that, forward to the problem at hand.

My FPS character that I made myself because the built in one did not suit my purpose walks into a cylinder. This cylinder is in fact a portal. I do not ask for being able to see through it, I just want to transport. Right now, I am happy if ANYTHING can get through it.

I attached the following code to the portal.

function OnTriggerEnter (other : Collider) {    
    Debug.Log("Somethin'");
    if (other.CompareTag ("Player")) { 
           other.transform.position = Vector3(0,0,0);
    }     
}

And quite plainly, it does not do anything. I can stand on the portal, I can blast it, I can jump into it, but I do not arrive at position 0, 0, 0. It does not even write "Somethin'". The code is clearly not called upon.

Many of you probably silently thought about how stupid and easy a mistake I have made. Please tell me what it is.

Thank you. Sincerely, PlatinumSkink

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 PlatinumSkink · Jan 03, 2011 at 04:50 PM 0
Share

Thank you very much. I had somehow (./) managed to not figure out that I must click on a box in the inspector view to make a certain code work. You have saved me from many hours of frustration.

I had not clicked the "Is Trigger" box, and I had not even registered that it existed. One less detail I will never have a problem with again, at least.

Thank you, Bob, for pointing this out to me. Thank you, Derek, for pointing out another fact that I was not aware of. I will now continue on my path of failing codes, and will probably return in a few moments.

Thank you. Sincerely, PlatinumSkink.

2 Replies

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

Answer by PrimeDerektive · Jan 03, 2011 at 04:23 PM

Does your FPS character have a Rigidbody or a CharacterController component? Without either of those, OnTriggerEnter can never fire.

Comment
Add comment · Show 3 · 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 Bob5602 · Jan 03, 2011 at 04:40 PM 0
Share

Also, make sure the thing that you are colliding with isn't just a collider, but a "trigger." There is a "is trigger?" checkbox on the collider that needs to be checked, or the onTriggerEnter code will never be called. Alternatively, just change the code to OnCollisionEnter and see if it works.

avatar image PlatinumSkink · Jan 03, 2011 at 04:42 PM 0
Share

It has a Rigidbody, though not a CharacterController. I found I did not need it for my purposes, and in fact, as my controller is now adding a CharacterController would create complete chaos and errors everywhere. I hope a Rigidbody is sufficient.

avatar image PrimeDerektive · Jan 03, 2011 at 04:54 PM 0
Share

Yeah, a rigidbody should be fine. As bob said, do you have "is Trigger" set to true on the collider component of the transporter thing?

avatar image
2
Best Answer

Answer by Statement · Jan 03, 2011 at 04:40 PM

  • It could be that you have not the script on the same object that has your collider, on the portal.
  • Or your player might lack a collider.
  • Or your players collider is a trigger.
  • Or your collision masks could be wrong.

If you create a box or something and attach a rigid body to it and let it fall into the portal, does it trigger the "Somethin'" message? If it does, then it sounds likely that either:

  • Your player have no collider.
  • Your player have inappropriate collision masks.

If it doesn't register the message even with the rigidbody, then your object might not have the script and trigger attached on the same object.

I have answered a similar question that might add more insight. I felt this was related so I crosspost.

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 PlatinumSkink · Jan 03, 2011 at 05:01 PM 0
Share

Wow. Thank you. I may have already solved the problem from reading what Bob wrote, but you offered me an alternative way of solving the entire teleporting issue. $$anonymous$$y game is pretty teleporter heavy, so this may come of great help. Thank you.

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

No one has followed this question yet.

Related Questions

Help with a simple function. 1 Answer

What is the code for detecting a collision? 1 Answer

Collision.point not working 1 Answer

Realistic Hands and Physics implementation? 1 Answer

Anti-Gravity vehicle bounce-back? 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