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 luizfsotero · Mar 19, 2013 at 08:08 PM · collisionphysicsrigidbody-collisionpool

Fast Physics for a pool game

I'm making a game similar to a pool game. That means I have a board with balls that collide with each other and with the board.

The physics Unity implements is perfect for the game, it even has drag and angular drag which makes the simulation quite real.

The problems is that when I apply a considered amount of power to the ball, on the next frame, it is already beyond the table and the physics don't apply, the ball simply passes through the walls.

After looking up a little on the internet I found the DontGoThroughThings script and other tips about collisions, but none of them worked, because the ball simply goes too fast for the physics to handle.

I don't think it's smart to recreate all the physics Unity uses just because Unity can't handle high speed objects.

I'm blind here on this topic... Don't know what to do... Is there a way to use Unity physics to work on high speed objects? Is there a game which has this kind of physics and the source is opened?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Mar 22, 2013 at 09:26 PM

In your case i would simply recommend to increase the physics framerate (lower the fixedTimeStep in Time settings). The problem is when you want very fast but accurate physics you need a high sample rate or you will miss "something". However a high physics framerate might be too much for your PC / device.

Unfortunately Unity doesn't allow to manually drive the physics system. That way you could precalculate some frames by using an initial delay. Something like that could be faked by having a duplicate of your pool table off screen and simulate the physics there. During simulation you could record the positions / rotations and replay them on the visual table without physics, but that's not easy to get it smooth.

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 luizfsotero · Mar 23, 2013 at 01:43 PM 0
Share

Thanks... Increasing the physics framerate gave me more range to get faster balls... It doesn't solve my problem, but it will be sufficient for a prototype.

avatar image
0

Answer by Dave-Carlile · Mar 19, 2013 at 08:26 PM

Try setting the rigodbody's collision detection mode to continuous.

Some additional info here: http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html

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 luizfsotero · Mar 22, 2013 at 08:05 PM 1
Share

It doesn't change a thing. I already changed all the settings to continuous dynamic. It's just too fast for the collisions... the balls go through the walls

avatar image
0

Answer by EugeneGillmer · May 02, 2020 at 10:28 PM

Just came across this and thought i would put in my 2 cents for future generations...

Firstly make sure you are applying force to the rigidbody and not just altering the transform (obvious for some but everyone makes this mistake at first!)

 //put this code on the ball you want to move

 Rigidbody ball_rb = GetComponent<Rigidbody>();
 Vector3 direction = pool_cue.transform.forward; //normalized value to multiply by speed value
 float speed = 5f; //adjust this to suit your needs
 ball_rb.AddForce(direction * speed, ForceMode.Impulse); //this should to the trick!

 //ForceMode from Unity docs
 //Force             Add a continuous force to the rigidbody, using its mass.
 //Acceleration      Add a continuous acceleration to the rigidbody, ignoring its mass.
 //Impulse           Add an instant force impulse to the rigidbody, using its mass.
 //VelocityChange    Add an instant velocity change to the rigidbody, ignoring its mass.


This does not fully solve the problem yet but its a step in the right direction. Next, widen your colliders on your table walls, make sure they are wide enough so the balls cant slip past them in between frames.

In Edit -> Project Settings -> Physics you can adjust default solver iterations for more accurate physics (use with care, can be processor-heavy)

I have seen many people reference to decreasing the fixed timestep in Edit -> Project Settings -> Time, but all this does for me is slow the game down. Perhaps it will work for you.

If your balls are still not moving to your liking, try reducing the drag, angular drag and weight on the balls' rigibodies. Apply a bouncier physics material with less friction to the balls' colliders.

Hope this helps!

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

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

Related Questions

Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Knock down moving target ridigbody from collision. 1 Answer

How do I "remove/disable" collision? 3 Answers

Force physics collision calculation (forced fixed update) 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