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
1
Question by permanentrecords · Apr 11, 2015 at 08:14 PM · unity 5physicsrigidbodies

What is causing this odd physics behaviour?

The ball in my skeeball style arcade game rolls along a flat plane until it hits a ramp. The plane is FLAT. I have double and triple checked. There are no vertices or anything in the path, and everything is parallel. There is nothing else that affects rigidbodies there. In one specific place, just right of centre, the ball manages to get slightly deflected, as if there were some invisible bump. Here is a video showing what happens:

https://www.youtube.com/watch?v=ehqtocYnCJ8

This didn't happen on Unity 4.6, and I hadn't noticed it until the last update to the game (where I changed unrelated code, not affecting the ball or game table in any way.) In fact I hadn't noticed until someone brought it to my attention. It's only a small bump, but it is a physics based game, and when you throw hard enough to actually make a shot it can really throw the ball out of whack, or even off the table!

Here is the code for the ball movement, but by the time the ball has reached the glitchy bit, the user has no control and it is riding on the physics engine alone.

 using UnityEngine;
 using System.Collections;
 
 public class Ballthrow : MonoBehaviour {
     
     public float speed;
     public bool intheZone = false; 
     public GameLogic gLogic;
     public ballTrigger balltrigger;
     public Settings gameSettings;
     public bool canControl;
     
     
     void FixedUpdate ()
     {
         
             
                 //control the ball if you are in the ball zone!
                 if ((intheZone) == true) {
                         Time.timeScale = 1F;
                         
                         
                 }
                 if ((intheZone) != true) {
                         canControl = false;
                         if (Input.GetButtonDown ("SlowMo")) {
                                 Time.timeScale = 0.4F;
                         }
                 }
             if ((canControl) == true) 
             {
             if(Input.GetAxis("Mouse X") < 0.1 && Input.GetAxis("Horizontal") < 0.1 && Input.GetAxis("Mouse Y") < 0.1 && Input.GetAxis("Vertical") < 0.1)
             {
                 this.GetComponent<Rigidbody>().velocity = Vector3.zero;
             }
             float moveHorizontalm = (Input.GetAxis ("Mouse X") * gameSettings.sensX);
             float moveHorizontalj = (Input.GetAxis ("Horizontal") * gameSettings.sensX);
             float moveVerticalm = (Input.GetAxis ("Mouse Y") * gameSettings.sensY);
             float moveVerticalj = (Input.GetAxis ("Vertical") * gameSettings.sensY);
             Vector3 movementm = new Vector3 (moveHorizontalm, 0.0f, moveVerticalm);
             Vector3 movementj = new Vector3 (moveHorizontalj, 0.0f, moveVerticalj);
 
             GetComponent<Rigidbody>().AddForce (movementm * speed * Time.deltaTime);    
             GetComponent<Rigidbody>().AddForce (movementj * speed * Time.deltaTime);
             }
                     
                     }
             
             
     
 
 public void goHome()
 {
     transform.position = new Vector3(0f, 1.5f, -4.4f);
 }
 
     public void goAway()
     {
         transform.position = new Vector3(-10.549f, 9.0336f, -43.464f);
     }
 
     
     public void ballDelay()
     {
         StartCoroutine  (waitForIt() );
     }
 
     IEnumerator waitForIt() {
                 //Debug.Log ("Ball reset");
                 yield return new WaitForSeconds (2);
 
                 canControl = true;
         }
 
 
 
 }

Comment
Add comment · Show 6
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 KalleH · Apr 11, 2015 at 08:24 PM 0
Share

Does the ball have any scripts attached to it? If so, could you possibly post them, please.

avatar image cariaga · Apr 11, 2015 at 08:32 PM 0
Share

my suspect is a addforce and constant force code is affecting it

avatar image KalleH · Apr 11, 2015 at 08:55 PM 0
Share

Does moving the light change the position where that bump occurs?

avatar image permanentrecords · Apr 11, 2015 at 09:03 PM 0
Share

Nope, moving/deleting/disabling the light does nothing.

avatar image maccabbe · Apr 11, 2015 at 09:11 PM 0
Share

Does the ball use a sphere collider or mesh collider?

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

NonKinematic Rigidbody moved with Rigidbody.MovePosition not interacting with other NonKinematic Rigidbody as expected. 0 Answers

Similar movement to a game (look description) 1 Answer

Rigidbody.MovePosition not really smooth 2 Answers

Physics.overlapSphere doesnt detect colliders,Physics.CheckSphere doesn't detect colliders 1 Answer

OnTriggerEnter for parent AND child. 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