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 Ebil · Nov 27, 2011 at 08:01 PM · collisionrigidbodycollidershootingray

Fast object on collider not working

Hello,

I got a Problem with Fast Objects (ie. a Bullet) hitting a collider (crate or anything). I got this fix for the problem

http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings

But its not working completly. It is now always hitting the box, but the hit effect (little explosion) is on a somewhere completly wrong postion, and I dont know how to fix that.

This is my script for the collision:

     var deto : Transform;
 
 function OnCollisionEnter(collision: Collision)
 
 {
 
     if (collision.gameObject.tag == "SteelBox") {
 
       var detonate = Instantiate(deto, transform.position, Quaternion.identity);
 // If I change it to           var detonate = Instantiate(deto, transform.position, Quaternion.identity);
 // It will hit but it looks like its detonating inside of the box.. so no solution -_-
   Debug.Log("hit");
 
     Destroy(gameObject,0);
 
   }
 }

This is the script for my shot:

 public var bulletMesh : Transform;
 public var bulletSpeed : float=1000;
 public var delay : int = 10;
 function Update () 
 {
     delay--;
     if (delay < 1) {
     if(Input.GetButton("Fire1")) 
     {
         if(!bulletMesh || !bulletSpeed) 
         {
             Debug.Log("[Shoot] 'bulletMesh' or 'bulletSpeed' is undefinied");
         }
         else
         {
         var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
         
         var bulletCreate = Instantiate(bulletMesh, GameObject.Find("SpawnPoint").transform.position, Quaternion.identity);
         bulletCreate.rigidbody.AddForce(transform.forward * bulletSpeed);
         }
     delay = 10;
     }
     }
 }

I hope someone knows where the problem lies :/ Thanks in advance

Comment
Add comment · Show 3
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 FLASHDENMARK · Nov 27, 2011 at 08:51 PM 0
Share

I don't think using "DontGoThroughThings" is needed any more with 3.x. Back in the "old" days of 2.x Unity did not have proper collision detection to prevent objects going through objects. Now you can set the "collison detection" in the rigidbody component to a more CPU expensive one to prevent objects going through other objects.

So pretty much the above script is a "hack".

avatar image anwe · Nov 27, 2011 at 08:59 PM 0
Share

no, I think he's right, 'cause having small rigidbodies objects sometimes the collision fails, so it's really convenient to use the raycast solution(which is contained in the script mentioned)

avatar image Ebil · Nov 28, 2011 at 03:54 PM 0
Share

Well it is not affected by the size of theobject. Even if I enable that its a continous dynamic object ( and the object to collider with) it doesnt change. I increased the size of the collider, optimised the speed, removed the dontgetthrough script, and will life with that i think =o If its fast it hit the object inside and the collusion on the surface of the object is not completly visible, if it is very fast, it goes through the object.

skinWidth does not change anything, regardless of the value =o

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by anwe · Nov 27, 2011 at 08:24 PM

Probably u have set the variable skinWidth in the "DontPassThroughThing.js" too high, try 0.1-0.2, otherwise u'll get this terrible error!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Trouble with OnCollisionEnter and Exit 1 Answer

Avoid Player bouncing when colliding with objects 3D 1 Answer

Why is the Rigidbody ignoring Colliders? 1 Answer

Collision Only being detected on one of the objects involved in the collision - C# 0 Answers

3d models do not have collisions between them 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