• 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
Question by kurai · Feb 05, 2013 at 04:08 PM · collisionrigidbodybounce

Collision failing on fast moving object

Given this script, I used it on a cylinder moving across a field (it is suspended in the air, without gravity influence). Four static cubic colliders act as walls, defining a simple rectangular bound. The cylinder has a capsule collider and a physics material with bounciness 1. It has a small mass (0.1) and a little drag (0.01).

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMovement : MonoBehaviour {
     private float x;
     private float z;
     public float speed=1200f;
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         x= Input.GetAxis("Horizontal")*speed*Time.deltaTime;
         z= Input.GetAxis("Vertical")*speed*Time.deltaTime;
         if (Mathf.Abs(rigidbody.velocity.x)<90&&Mathf.Abs(rigidbody.velocity.y)<90)
         {
             rigidbody.AddForce (x,0,z);
         }
     }
     
     void Update (){
         print(rigidbody.velocity);
     }
 }
 

Problem is, with speed set at 1200 (which is fast and reactive, considering the Time.deltaTime multiplayer), the collider often fails, making the cylinder pass through the wall. I tried to divide the fixed timestamp by half, with no result. The object is quite fast, but it's certainly not a bullet (it is meant to be controlled by the player), so these errors seem quite strange to me.

Is there anything else I can do to improve the collision detection? I tried to set the rigidbody parameter as Continuous Dynamic, with no results whatsoever.

Comment

People who like this

0 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 Professor Snake · Feb 05, 2013 at 04:25 PM 0
Share

Perhaps you could consider lowering the fixed timestep in Project Settings->Time a bit more, or making your object go slower in general.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by haroonalam · Feb 05, 2013 at 04:37 PM

Try making Rigidbody collision detection to Continuous, go to Edit->Project Settings->Physics, make penetration lower and solver count high. Hope it may help.

Comment

People who like this

0 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 kurai · Feb 06, 2013 at 10:11 AM 0
Share

I made pretty much everything and reached an almost satisfying solution. Then I tried to add another cylinder with a rigidbody to simulate a ball. Trainwreck. The ball almost always loses the collision detection. What's worse, it never recovers it. It just becomes non-collidable. A total mess :(

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

bounce and roll a die 2 Answers

Collision misses - possibly not bullet through paper! (now with video) 1 Answer

How physical materials affect collision between rigidbodies? 1 Answer

Both Kinematic and Non-Kinematic behaviours at the same time. 1 Answer

How to make Sprite not Bounce on Collision (2D) 6 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