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 em2 · Aug 10, 2011 at 03:19 AM · collisiontransformgravity

Collision / Gravity Problem Not Updating and Pass through

Hi all, I'm having a problem with a simple collision / gravity setup. I have a sphere with a rigid body component so are using Unity Physics. Collision Detection is set to Continuous Dynamic and set to use gravity. I have made a basic enclosed area with cubes (like a simple maze, and sat the sphere inside). Each wall is a child of an empty game object simply called Maze (so I can reference them collectively). There is a box collider set on each of the walls. I have written a script which simply rotates the maze using the left and right arrow keys (this seems to work, see below).

 //rotates the object
 var speed = 50.0;
 function FixedUpdate () {
 var z = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
 transform.Rotate(0, 0, z);
 }


This script is attached to the Maze object. When I hit play, the sphere drops appropriately and lands on the bottom wall (sphere has a z constraint so it doesn't roll off the side) . Then when I hit the left and right keys the maze is rotated correctly.

The problem I'm having is that the ball sometimes rolls along the rotated wall as it is supposed to, and other times it doesn't. Sometimes, after the sphere has initially hit and stopped, the maze can be rotated straight through the sphere. It seems to take a few seconds and then the sphere operates under gravity again, and falls as it should.

The things I have tried is increasing the mass of the sphere, changing the script from Update to FixedUpdate, changing the box colliders to mesh colliders, and changing the collision from Continuous Dynamic to Dynamic.

In the stats this scene is running at between 60 and 70 fps so doesn't seem to be a performance issue. I'm obviously doing something wrong. Any suggestions would be appreciated.

Best Regards Chris

Comment
Add comment
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

1 Reply

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

Answer by em2 · Aug 10, 2011 at 11:57 PM

I think I've fixed it. The problem appears that the gravity on the sphere was going to sleep. I put the following script on the sphere, and although there is no actual force applied, it does keep the object forces 'awake'. As I'm new I would appreciated if anyone could let me know if there is a better solution, or if I have implemented it poorly.

 //Script on the sphere
 function FixedUpdate(){
 rigidbody.AddForce(0,0,0); 
 }


Cheers Chris

Comment
Add comment · 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

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

2 People are following this question.

avatar image avatar image

Related Questions

Enemy behavior help 1 Answer

Can't get gravity to work proberly (transform) 2 Answers

How do I increase the size of a GameObject when my firstperson character approaches/collides with it? 1 Answer

Disable a script on collision 2 Answers

Ignore Collision Temporarily 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