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 schwertfisch · Jan 09, 2011 at 09:19 PM · instantiatecollidertriggerspawn

Instantiated (clone of) prefab, doesn't trigger another object's collider when inside it.

When certain things happen, I have a prefab (objectA - the prefabs clone that gets instantiated) instantiated at the position of an empty gameObject (objectB) with a collider component that works as a trigger.

Generally, when any object enters objectBs collider, objectBs tag changes to something and when the other object exits objectBs collider, objectBs tag reverts to its initial value (see js below).

The problem is that when the objectA gets instantiated on objectB, objectB doesnt seem to "notice" it. I hit pause and select objectB in the Scene view and verify that its tag has remained unchanged, even though objectA (the prefabs clone) has entered objectBs collider.

Whats strange, is that when I touch objectBs (as I said, this is the empty game object with the collider) translate gismo (the game is paused still), the tag immediately changes as it was supposed to. The objectBs position doesnt change when I do this, maybe just one or two tenths of distance units, but the malfunction definately has nothing to do with my colliders not being inside one another - I made objectAs collider big enough.

Does anyone have an idea why this happens?

The script that's attached to objectB and controls its tag, depending on whether another gameObject is inside its colliders boundaries or not is the following simple js:

function OnTriggerEnter(other : Collider) { gameObject.tag = "VacancyTesterFull"; }

function OnTriggerExit(other : Collider) { gameObject.tag = "VacancyTesterEmpty"; }

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

2 Replies

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

Answer by schwertfisch · Jan 10, 2011 at 09:45 PM

Being a Unity novice, I hadn't attached RigidBody component to objectA and that caused the problem. Thanks again Tuck for bothering to answer :)
(I'll have to wait a day before checking my own answer)

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 Tuck · Jan 10, 2011 at 06:30 AM

I'm not a hundred percent on this, but since you're spawning objectA directly on top of objectB, it never 'enters' the trigger per se, it just is suddenly in it, so OnTriggerEnter is never called. Trying changing from OnTriggerEnter to OnTriggerStay. If that doesn't work I do not correctly understand your problem.

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 schwertfisch · Jan 10, 2011 at 08:43 PM 0
Share

Thanks for answering Tuck. I had already done that, because like you I had the same thought. I instantiate ObjectA 2 units below ObjectB and have it move very fast 2 units upwards, inside ObjectB. ObjectB's tag does not change to "VacancyTesterFull". When I hit pause and just touch the objectA's translation gizmo, objectB's tag changes to "VacancyTesterFull" (as wanted) and it seems like the engine needs something else to take notice of objectA's position.

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

Is it possible to convert a Collider into a Spawner? 0 Answers

Which setup should I use for spawning? 0 Answers

Spawning explosions and detecting objects in range 1 Answer

Spawn OnTriggerEnter 0 Answers

Trigger Spawning? 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