• 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 kobyfr · Oct 23, 2020 at 11:11 AM · physics2dsimulationmomentumaccuracy

elastic collision simulation loses 400 kgm/s momentum in a few hours

I have made a 2D simulation of 20 balls enclosed within 4 walls, each with a velocity magnitude of 20 units/s, each with a mass of 1. all rigidbodies and colliders are elastic - 0 for friction, 1for bounce.

Initial conditions

  • The velocity sum along the x axis is 240.

  • The velocity sum along the y axis is 160.

  • The sum of |V|*m was 400 (20*20) at start, and I continuously printed that sum on screen, while the balls went on colliding within these 4 walls.

During runtime

  • after 1 second : sum = 360

  • after 10 minutes : sum = 250

  • after 4 hours : sum = 0

Motivation

Why did I do this simulation? because the ball in my arkanoid-style game loses speed over time, and I wanted to find out why. Is this due to the physics engine? shouldn't I rely on it to be accurate enough for at least a few minutes, without a need for runtime-corrections-by-code?

I know this sum does not represent how conservation of momentum works, but I start with non-zero momentum on both axis, so the simulation should not never get to 0 speed for all 20 balls.

[1]: /storage/temp/169702-untitled.jpg

untitled.jpg (361.5 kB)
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 kobyfr · Oct 23, 2020 at 12:54 PM 0
Share

Switch to calculating kinetic energy (0.5 m v^2) instead of momentum. found that the kinetic energy is not constant. After a few seconds, it is reduced from 4000 (0.5 20 400) to 3991.1, then it rises above 4000 to 4235, and simply is not constant as physics mandates. I aught to add that 1. the balls in the simulation have their Z rotation frozen 2. all objects (walls, balls) have interpolation active, and collision detection is set to "continuous".

1 Reply

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

Answer by kobyfr · Oct 23, 2020 at 12:03 PM

Is it possible to modify the parameters in "Physics 2D" to achieve a more accurate simulation?

physics 2D offset


untitled.jpg (71.4 kB)
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 kobyfr · Oct 23, 2020 at 01:49 PM 0
Share

yep, setting velocity threshold from 1 to 0.0001, get's the job done, and reduces the energy loss to a minimum.

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

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

Related Questions

Simulating a Rubber Band 0 Answers

Are point effectors (2D) simulated when you use the physicsscene2d simulate function? 1 Answer

Inaccurency BoxCast2D,Inaccuracy BoxCast2D 0 Answers

What is the best way to implement physic simulation prediction for AI in Unity? 1 Answer

2D physics, animation-controlled kinematic colliders not affecting momentum 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges