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 Ekta-Mehta-D · Mar 19, 2013 at 08:08 AM · collisionsphereoverlap

Sphere Overlap EachOther

I have dynamically generated sphere at specific position. And when i shoot new sphere , i am assigning nearest empty position to collision contacts to that new sphere.

You can see in my previous question.

So all these works for my first row. And again when i shoot it overlapes that shooted sphere. I want to stop that sphere on collision.

code that i have written in OnCollisionEnter :

 function OnCollisionEnter(collision : Collision )
 {        
         if(transform.parent == null) // for bullet sphere , parent is null .. So collision work only for bullet
         {            
             var contact : ContactPoint = collision.contacts[0];
             var pos : Vector3 = contact.point;    
             var t : Transform = ClosestTransform(pos);
             transform.position = t.position;
             transform.rigidbody.velocity = Vector3.zero;
             transform.rigidbody.angularVelocity = Vector3.zero; 
             transform.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
             
                 if(bubbleId.Equals("Blue"))
                 {
                     t.gameObject.tag = "spawnpointBlue";    //changing tag
                     scriptRandomSphereObj.blueSpawnPoint = GameObject.FindGameObjectsWithTag("spawnpointBlue");            
                     l =  scriptRandomSphereObj.blueSpawnPoint.length;
                     Debug.Log("length :" + l);    // checking length.
                     transform.parent = t.transform; // assign parent
                 }
                 else if(bubbleId.Equals("Red"))
                 {
                     t.tag = "spawnpointRed";                    
                     l =  scriptRandomSphereObj.redSpawnPoint.length;
                     Debug.Log("length :" + l);
                     transform.parent = t.transform;    
                 }
                 else if(bubbleId.Equals("Green"))
                 {
                     t.tag = "spawnpointGreen";                    
                     l =  scriptRandomSphereObj.greenSpawnPoint.length;
                     Debug.Log("length :" + l);    
                     transform.parent = t.transform;
                 }
                 else if(bubbleId.Equals("Yellow"))
                 {
                     t.tag = "spawnpointYellow";                        
                     l =  scriptRandomSphereObj.yellowSpawnPoint.length;
                     Debug.Log("length :" + l);    
                     transform.parent = t.transform;
                 }
                 else if(bubbleId.Equals("Purple"))
                 {
                     t.tag = "spawnpointPurple";        
                     l =  scriptRandomSphereObj.purpleSpawnPoint.length;
                     Debug.Log("length :" + l);    
                     transform.parent = t.transform;
             }
                 
         }    
 }

In update function :

 if(Input.GetMouseButtonDown(0))     
     {    
         emptyObject = GameObject.FindGameObjectsWithTag("Empty");
         for(var i : int = 0 ; i < emptyObject.Length ; i++)
         {
             emptyList.Add(emptyObject[i].transform);
         } 
         Debug.Log("length " + emptyObject.Length);
 }

From these arraylist , i am taking nearest empty position.

So why my sphere not detecting collision ?? Pleaze solve my issue.

Comment
Add comment · Show 7
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 robertbu · Mar 19, 2013 at 08:33 AM 0
Share

I'm confused about your issue. Are you talking about a small overlap or does it just not detect the collisons? Consider setting the is$$anonymous$$inematic to true to stop your bubbles.

avatar image Ekta-Mehta-D · Mar 19, 2013 at 08:59 AM 0
Share

it is not detecting collision..

avatar image Ekta-Mehta-D · Mar 19, 2013 at 09:00 AM 0
Share

I have checked by setting iskinematic to true.. but same thing happens..

avatar image robertbu · Mar 19, 2013 at 09:43 AM 0
Share

I don't know the Physics engine as well as I know other parts of Unity. Try setting collision detection mode in the Rigidbodies to "Continuous" or "Continuous Dynamic". Go to to Edit/Project Settings/Physics and set sleep velocity to 0.0. You are moving your "ball" through AddForce()?

avatar image Ekta-Mehta-D · Mar 19, 2013 at 11:24 AM 0
Share

yes sir.

 function Update ()
 {
     if(transform.parent == null)
     {
           var hit : RaycastHit ;
           var ray : Ray  = Camera .main .ScreenPointToRay (Input .mousePosition );
           if(Physics.Raycast (ray, hit)){     
              var tempx = hit.transform.position.x;
              var tempy  = hit.transform.position.y;
              target = Vector3(tempx,tempy,0);
           }
             if(target != null){
             var moveAmount : float = 5000 * Time.deltaTime;
             transform.rigidbody.AddForce(transform.TransformDirection(target) * moveAmount);            
          }   
      }
 }
Show more comments

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

10 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

Related Questions

A node in a childnode? 1 Answer

Colliders with JS only 2 Answers

What is the best way to script third person real-time action melee combat in C#? 0 Answers

Can you have different collision box type with one gameobject. 1 Answer

Is this Possible to force gameobjects (coliders etc) to get stretched based on the aspect ratio of the screen? 0 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