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 /
  • Help Room /
avatar image
0
Question by jzylinski · May 26, 2020 at 01:32 AM · colliderscollision detectiontriggersattribute

onTriggerEnter returns wrong object's attribute

I'm trying to do something a little different...I'm modifying @godlikemouse 's Topology script (link:https://collaboradev.com/2014/03/12/visualizing-3d-network-topologies-using-unity/) with the objective of only displaying node labels when the nodes are within the trigger area of a collider attached to the camera in order to reduce the work load of having so many gameObjects (I have ~16k nodes and 23k edges and all those gameObjects are a drag). I have a collider on my camera that reacts to the proximity of nodes, which I've tested through print() statements. It is indeed triggering when a node is nearby and it returns a node name. Unfortunately, every time it triggers it returns the same name...no matter which node hits the collider first. For example, I could hit nodes in this order: A, B, C and it will print W, W, W. Then I restart, go a different route and hit nodes E, F, G but it will still print W W W. I've tested it with godlikemouse's default render settings and was able to see the names were legitimately propagating to individual NodeObject values, and I've reviewed the raw data I'm using so I'm pretty certain the graph data isn't the problem.

I've also tried multiple collision Detection settings, which don't seem to make a difference. The nodes I'm colliding with are all prefab cylinders with sphere colliders. Any ideas as to why it's just repeating the same name over and over again for all nodes?

Here's what the collider looks like:

 private void OnTriggerEnter(Collider nearby_object)
     {
         if (nearby_object.tag == "NodeTag")
 
             ///  OBJECTIVE 1: Retrieve the `NodeText` attribute for a given node (the node's name)
             ///  OBJECTIVE 2: Instantiate game space canvas
             ///  OBJECTIVE 3: Render the name to the canvas
             ///  OBJECTIVE 4: Destroy canvas upon collider exit
             ///
         {
             //Get the nodeText attribute!
             string node_name = nearby_object.GetComponent<Node>().nodeText.text;
             print(node_name);

But then by golly, here's my print statement for each-and-every node that enters the trigger area: 0020-0012-5980-1232 (a string of a node name) UnityEngine.MonoBehaviour:print(Object) Ad infinitum, same name. I'm stumped. If you have an idea of how to fix this, please lend a hand!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jzylinski · May 26, 2020 at 12:35 PM

Update...I got over the hump. What was happening is, the textMesh prefab's .text attribute was getting overwritten each time a new node was instantiated. This was fine for the way @godlikemouse mouse made it in which the prefab is instantiated along with the node, but if you don't make the prefab, the data that was fed to that textMesh isn't being perpetuated. I replaced the textMesh in the node.cs and gamecontroller.cs scripts with a plain string variable. Now when I travel around and my trigger pops, it prints the proper names of the nodes. Glory Hallelujah!

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

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

Trigger a box collider based on force of an object 1 Answer

Prevent changing speed at collision 0 Answers

How do I detect a collision between two objects using Bolt? 1 Answer

How do I make "selective" borders? 0 Answers

Player is in range of an Item or Door and can Interact? 2 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