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
2
Question by WardPeeters · Apr 03, 2015 at 12:46 PM · colliderpinball

Fast moving ball ignores colliders.

Hello

I'm making a pinball game in unity. When the ball is at high speed it sometimes ignores the flipper colliders. Is there a better way then colliders to prevent my ball from going through?

Thanks for reading.

Comment
Add comment · Show 1
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 ozturkcompany · Apr 03, 2015 at 12:53 PM 0
Share

When it comes into physics, you should always take care to use your physics code inside FixedUpdate(). To prevent undesired collisions and collosion detection, you could increase the solver iteration count, $$anonymous$$ contact penetration.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by sparkzbarca · Apr 03, 2015 at 12:58 PM

go into the rigidbody settings of the ball AND flippers and set collision detection from discrete to continuous dynamic for both.

As long as it runs smooth still leave it like that (that kind of collision detection that doesnt allow for the risk of something passing through the object by skipping past it in a frame is calculation intensive and it may cause your frame rates to drop)

If it does you need to add a little thickness to the flippers and there colliders so there a little bigger.

cap the speed of the ball to less meters per frame than say half the thickness of the flippers.

so lets say your flippers are 1 unit thick. You have 60 fps by default for physics. So you have 1/60th of a second distance you basically teleport each frame.

if you are 1 meter thick that means in 1/60th of a second it has to go less than half a meter. scaled up thats 30 meters per second cause its .5 * 60.

you need to clamp your balls velocity (the flipper may be moving too and you may have to play around with this some to get consistent results, but that'll give yuou a good starting point)

30 meters per second is around 70 miles per hour so thats a pretty quick moving pin ball.

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

Answer by gkepets · Apr 03, 2015 at 12:48 PM

try this script:

 #pragma strict 
  
 var layerMask : LayerMask; //make sure we aren't in this layer 
 var skinWidth : float = 0.1; //probably doesn't need to be changed 
 private var minimumExtent : float; 
 private var partialExtent : float; 
 private var sqrMinimumExtent : float; 
 private var previousPosition : Vector3; 
 private var myRigidbody : Rigidbody; 
 //initialize values 
 function Awake() { 
    myRigidbody = rigidbody; 
    previousPosition = myRigidbody.position; 
    minimumExtent = Mathf.Min(Mathf.Min(collider.bounds.extents.x, collider.bounds.extents.y), collider.bounds.extents.z); 
    partialExtent = minimumExtent*(1.0 - skinWidth); 
    sqrMinimumExtent = minimumExtent*minimumExtent; 
 } 
  
 function FixedUpdate() { 
    //have we moved more than our minimum extent? 
    var movementThisStep : Vector3 = myRigidbody.position - previousPosition; 
    var movementSqrMagnitude : float = movementThisStep.sqrMagnitude;
    if (movementSqrMagnitude > sqrMinimumExtent) { 
       var movementMagnitude : float = Mathf.Sqrt(movementSqrMagnitude);
       var hitInfo : RaycastHit; 
       //check for obstructions we might have missed 
       if (Physics.Raycast(previousPosition, movementThisStep, hitInfo, movementMagnitude, layerMask.value)) 
          myRigidbody.position = hitInfo.point - (movementThisStep/movementMagnitude)*partialExtent; 
    } 
    previousPosition = myRigidbody.position; 
 }
Comment
Add comment · Show 3 · 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 WardPeeters · Apr 05, 2015 at 02:03 PM 0
Share

Hello thanks for posting. Could you explain this script a little bid for me please?

avatar image gkepets · Apr 09, 2015 at 02:45 PM 0
Share

i dont know too much about it, but i know it uses raycasting to set an extra boundary around the object. I found it here: http://wiki.unity3d.com/index.php?title=DontGoThroughThings

avatar image WardPeeters · Apr 10, 2015 at 05:45 PM 0
Share

Oke thanks I will look into it.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

PINBALL: Ball colliding problems 1 Answer

Internal collisions 1 Answer

Sphere with collider entering the flat surface 2 Answers

Design choice for collision 1 Answer

Read txt file into a game 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