• 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 Wachronos · Mar 18, 2016 at 12:49 PM · collisioninstantiaterandom

Instantiated objects ignoring collisions randomnly o.O

Hi guys!

I'm a bit lost here, I'm instantiating objects that are supposed to fall and hit the top of a cube. I have 4 prefabs that I instantiate randomnly at random positions above the cube. Then they fall and some of them hit the cube and stay there... some others just cross the cube... and ignore all collisions... I have no idea what this is happening... Do you have any idea?

I'm just instantiating using the usual initialization

 GameObject newInst = GameObject.Instantiate(objctList[selectedIdx]);
 newInst .transform.position = position;
 ....

Thanks!

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
1

Answer by Raresh · Mar 20, 2016 at 09:57 PM

It happened to me once when I started and wanted to make a cup thing that can hold spheres. The reason I think it is is that once the objects move fast enough, the physics engine doesn't detect any collisions because they pass through each other(because of the speed). I can think of 2 ways of solving this:

1) If the object they are falling on is a ground static type, make it a cube, and make it thicker so that it can detect the collision better

2) Make a raycast from the moving object to the target, once the raycast doesn't return that it hit the target, it means it passed it and should've stopped (if you keep the previous position you can teleport it back to the last known position)

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 Wachronos · Mar 22, 2016 at 04:39 PM 0
Share

mmmm it makes sense.... shouldn't happen, but it makes sense if that is the case. Thanks for the reply!

Initially the ground was already an object of the type cube and it was still allowing objects to pass through... I ended fixing the problem in another way... created another cube that is just slightly below the first "ground"...With both cubes, apparently most of the objects already stay in the "correct" place, i.e. on top of either cubes... I don't particularly like the solution, but it's one way to fix the problem. This way I could avoid the second solution :)

avatar image
0

Answer by Rob2309 · Mar 23, 2016 at 11:02 AM

If your falling cubes have RigidBody attached to them, you can just change the Collision Detection from Discrete to Continuous... This should fix your problem as long as the floor they are falling towards does not move :)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how to create random list of two diffrent prefab 1 Answer

Random spawn Gameobject in area 2 Answers

How can I instantiate only where there is free space? 1 Answer

Help moving turret shoot lasers 2 Answers

Spawning objects at points within another object? 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