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 SteveKF · Dec 30, 2015 at 04:18 PM · colliderthreadprimitivesintersectspider

Problem with the Intersect method

Hello Unity community,

I have a problem with the Intersect method because it says me some object intersect when they don't. I have a spider which spins threads. At each end of the thread there is a point which scales the thread accordingly (Rescale Script) I want to get all points which are on a thread. (=> They need to intersect)

In this example: alt text

In the following I have listed want points I wanted to get when I use the Intersect method:

Thread 1: Point 1, 2, 4

Thread 2: Point 1, 3, 5

Thread 3: Point 4, 5

However, my code returns me:

Thread 1: Point 1, 2, 4

Thread 2: Point 1, 3, 5

Thread 3: Point 1, 4, 5

I don't get why Point 1 intersects thread 3. I hope you guys can help me.

For simplification I have simplified the code for only this example.

Rescale Script

Scales the thread accordingly to its start and end point.

 using UnityEngine;
 using System.Collections;
 
 public class Rescale : MonoBehaviour {
 
     public Transform start;
     public Transform end;
     public bool completed = false;
 
     public float factor = 0.5f;
 
     void Start() {
         SetPos(start.position, end.position);
     }
 
     void Update () {
         if (!completed) {
             SetPos (start.position, end.position);
         }
     }
 
     void SetPos(Vector3 start, Vector3 end) {
         var dir = end - start;
         var mid = (dir) / 2.0f + start;
         transform.position = mid;
         transform.rotation = Quaternion.FromToRotation(Vector3.up, dir);
         Vector3 scale = transform.localScale;
         scale.y = dir.magnitude * factor;
         transform.localScale = scale;
     }
 }

Overlap Script:

Returns all points which intersect with the thread. (Script is attached to each thread)

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 
 public class CheckOverlap : MonoBehaviour {
 
     public List<GameObject> reachablepoints;
 
     // Use this for initialization
     void Start () {
         reachablepoints = new List<GameObject> ();
 
         GameObject[] points = GameObject.FindGameObjectsWithTag ("Point");
 
         for (int i = 0; i < points.Length; i++) {
             if (Intersects (points [i].GetComponent<Collider> ().bounds)) {
                 reachablepoints.Add (points [i]);        
             }
                 
         }
     }
 
     bool Intersects(Bounds bounds){
         bool overlapping = GetComponent<Collider>().bounds.Intersects(bounds);
         return overlapping;
     } 
 }
 


thread.png (44.8 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Check if object position not taken. 0 Answers

Instantiated Objects Inside of Walls 1 Answer

Finding name of gameobject that entered a trigger 0 Answers

How to draw a collider between two points 0 Answers

Character Controller and Rigidbody 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