Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 bageren · Sep 27, 2018 at 03:54 PM · addforcespherebounciness

Unexpected behavior from bouncing sphere

Hi, I'm playing around with some physics in unity. I've created a sphere and I am using the AddForce on it to move it along the x and y axis like so:

     void Start () {
         position = transform.position;
         ball = GetComponent<Rigidbody>();
         ball.AddForce(transform.right * xForce);
         ball.AddForce(transform.up * yForce);
     }

Once the ball hits the ground and starts bouncing, it's like a force is added to it on the z axis. You can see the behavior here: https://gyazo.com/aa80b05e0129c00dc925d1dc7891715c

I don't understand why this is happening. I wanted to the ball to bounce straight towards the red cube. Can anyone explain? I don't know if it matters, but I have 0 dynamic, 0 static, 0 bounciness physic material on my terrain and 0, 0, 0.8 on my ball.

Comment
Add comment · Show 5
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 OtunGroup · Sep 27, 2018 at 09:53 PM 0
Share

Hi, is your ball inside the ground? Try moving it upward so that it rests slightly above it. -Greg

avatar image bageren OtunGroup · Sep 27, 2018 at 10:34 PM 0
Share

Hi Greg, thanks for your reply. I did what you told me to but i didn't change anything. However, I have tried changing the mass of the ball which changed the behavior. When I set it to 0.5 ins$$anonymous$$d of 1, the ball is now able to bounce once the way i want it to, but on the second one it inexplicably bounces to the left, along the z-axis. Here is a gif that shows it.

avatar image OtunGroup bageren · Sep 27, 2018 at 10:36 PM 0
Share

This is very bizarre. What are you using for your ground? Is it perfectly flat?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by corpsinheretoo · Sep 28, 2018 at 02:53 AM

I am not sure what is going on. But try using Vector3.right and Vector3.up.

From Unity Docs:

Unlike Vector3.up, Transform.up moves the GameObject while also considering its rotation.

I am not sure why this would make a difference in your case but let us know if it works :).

***Update: Solved (probably). This took a lot of research for what seemed like a simple problem. Even a smooth terrain is made up of a bunch of triangles. I am guessing the ball is interacting with the seams. Settings>Physics>Default Contact Offset = 0.5 (default is 0.01) fixes this problem for me. I am not sure what repercussions there may be later in your development of your game though! Good luck and hope this helps.

Comment
Add comment · Show 10 · 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 bageren · Sep 28, 2018 at 10:30 AM 0
Share

Hi, that did not work unfortunately.

avatar image corpsinheretoo · Sep 28, 2018 at 06:03 PM 0
Share

You are welcome to send me your project (corpsinheretoo at gmail dot com) - I really want to know what is going on :)

avatar image bageren corpsinheretoo · Sep 30, 2018 at 03:32 PM 0
Share

Cool, I've send you an e-mail :)

avatar image corpsinheretoo bageren · Oct 01, 2018 at 08:33 PM 0
Share

I have not received an email :( (spam folder has been checked) corpsinheretoo@gmail.com

Show more comments
avatar image bageren · Oct 04, 2018 at 11:58 AM 0
Share

Alright, thanks for taking your time to look into this issue. So, would you recommend that I use a cube or the terrain moving forward?

avatar image corpsinheretoo bageren · Oct 04, 2018 at 06:04 PM 0
Share

That really depends on what you are trying to make! That is probably getting too off-topic for this thread but you are welcome to email me if you would like to discuss your project specifics more.

avatar image Casiell corpsinheretoo · Oct 04, 2018 at 09:35 PM 0
Share

Did you get to what's the issue? I'm really curious what's this about

Show more comments
avatar image JVLVince · Oct 05, 2018 at 02:41 AM 0
Share

I don't know this solution work or not but I have to mention one thing that changing some variable in setting will affect all project (in this case is the physics system of your project), it will (maybe can) simply solve this bouncing problem but the other part of your game (which using the unity physic system will take effect from this setting too), so make sure you already discuss with your $$anonymous$$m before change this setting. So let say, if this just a practice system, then it won't be a large problem but if this is a product, I'm sorry to say that this may be a bad solution. :(

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

95 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

Related Questions

how can i rotate the ball in left direction deirection if it was in forward direction and vice versa , like a real ball? 2 Answers

Sphere vs Capsule collider collision resolution 0 Answers

Sphere behaves strange by jumping on diagonal Plattforms or at terrain 0 Answers

re-orienting velocity 1 Answer

AddForce to sphere 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