• 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 Dan509 · Feb 07 at 06:43 AM · scripting problemphysicsbeginner

Ball bounces unexpectedly while rolling downwards

So I'm creating this game and its an endless ball roller type game, as of right now when the ball rolls downhill it bumps from time to time I don't know if its caused by misaligned platforms or some physics problem. The balls collision detection is set to continuous

I have attached my physics project settings alt text

alt text

Below is the spawning script

using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; public class PlayerCollision : MonoBehaviour { public TestCharacterController movement; public List startingDel; public List obPrefabs; public GameObject[] PrefabRoad; public GameObject player; public GameObject startingTele; public int setToTrue = 0;

  private void OnCollisionEnter(Collision collisionInfo)
  {
      if (collisionInfo.collider.tag == "Obstacle")
      {
          Debug.Log("WE HIT");
          movement.enabled = false;
      }
 
  }
  
 
  private void OnTriggerEnter(Collider other)
  {
 
      if (other.tag == "DelStart")
      {        
          Destroy(startingDel[0]);
          Destroy(startingDel[1]);
          Destroy(startingDel[2]);
          Destroy(startingDel[3]);
          movement.yForce = 0f;      
          player.transform.position = new Vector3(0, 118f, 158f);
          Destroy(startingTele);
      }
      if (other.tag == "SpawnTrigger")
      {
          MoveRoad();
      }
 
  }
  // Start is called before the first frame update
  void Start()
  {
      if (obPrefabs != null && obPrefabs.Count > 0)
      {
          obPrefabs = obPrefabs.OrderBy(r => r.transform.position.z).ToList();
 
      }
  }
  public void MoveRoad()
  {
 
      GameObject movedRoad = obPrefabs[0];
      obPrefabs.Remove(movedRoad);
      float newZ = obPrefabs[obPrefabs.Count - 1].transform.position.z; 
                                                                // Debug.Log(newZ);
      newZ += 26.6623f;       
                              
      float newY = obPrefabs[obPrefabs.Count - 1].transform.position.y - 4.7013f;
      //  Debug.Log(newY);
 
   
 
      movedRoad.transform.position = new Vector3(0, newY, newZ);
      obPrefabs.Add(movedRoad);
 
  }
  // Update is called once per frame
  void Update()
  {
      
  }

}

Here is the Character Script

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class TestCharacterController : MonoBehaviour { private Rigidbody rigidBody; public float zForce = 100f; public float yForce = 0f; private float xForce = 500f;

  // Start is called before the first frame update
  void Start()
  {
      rigidBody = GetComponent<Rigidbody>();
      
  }
 
  // Update is called once per frame
  void FixedUpdate()
  {
      
      rigidBody.AddForce(0, yForce, zForce * Time.deltaTime);   
      if (Input.GetKey("s"))
      {
          rigidBody.AddForce(0, 0, zForce * Time.deltaTime);
      }
      if (Input.GetKey("d"))
      {
          rigidBody.AddForce(xForce * Time.deltaTime,0,0);
      }
      if (Input.GetKey("a"))
      {
          rigidBody.AddForce(-xForce * Time.deltaTime, 0, 0);
      }
 
 
  }
  

}

ballroll.gif (496.4 kB)
physics.jpg (107.0 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 logicandchaos · Feb 07 at 05:16 PM 0
Share

maybe the gravity is not high enough, your picking up a lot of speed so your forward force might be more than your downward force.. hard to tell what is the issue.. could be a collision issue too.

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.

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

274 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 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

Make enemy follow and hit the player 3 Answers

How do I make a script that will allow my character to shoot projectiles? 1 Answer

Issue with spawn timing getting delayed,Issue with timing of BlockSpawner 0 Answers

Particular physics issue after a respawn of my ball Player... 0 Answers

Kinematic rigidbody shakes 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