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
0
Question by fabianzaf · Aug 31, 2012 at 09:19 PM · collisioncolliderjumpcuberotating

Object rotates from Y velocity on Collision

I have a simple plane and a cube in my scene, the cube has a rigidbody + box collider.

I have this script attached to the cube

 function OnCollisionEnter(collision: Collision) {
 
 
 rigidbody.velocity = rigidbody.velocity + Vector3(0,10,0);
 
 
 }

On every "bounce" the cube starts rotating, this is indicated by the trail renderer I've attached.

Why do you guys think its rotating? I cant seem to figure it out.

Any help is appreciated, thanks!

alt text

rotateissue.png (42.6 kB)
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

2 Replies

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

Answer by ScroodgeM · Aug 31, 2012 at 09:46 PM

physic calculations are mostly unpredictable. even in real life you will never get an ideal cube and ideal plane to jump directly in ideal direction.

you talking about rotating, but i see a moving on your screen.

anyway, to freeze rotations use rigidbody's properties

Comment
Add comment · Show 2 · 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 fabianzaf · Aug 31, 2012 at 09:50 PM 0
Share

Thanks for answering Scroodge!

I know that physics is unpredictable but something as straight forward as adding velocity on Y shouldnt do this unless some other factors are introduced?

I've actually locked the rotations however it still rotates.

I used: rigidbody.constraints = RigidbodyConstraints.FreezeRotationX; rigidbody.constraints = RigidbodyConstraints.FreezeRotationY; rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ;

The block rotates, its moving because its edge hit the plane and moved in the direction it was angled.

avatar image ScroodgeM · Aug 31, 2012 at 09:59 PM 0
Share

rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;

will be correct

avatar image
0

Answer by fabianzaf · Aug 31, 2012 at 10:26 PM

I've figured it out!

I had to go to edit > project settings > Physics

In the inspector you have to set Max Angular Velocity to 0, it stops it from rotating, not sure what the side effects are but at least it solves this problem.

Comment
Add comment · Show 5 · 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 ScroodgeM · Aug 31, 2012 at 10:27 PM 0
Share

you'd disable all rotations in scene. of course this can be a solution, if you really needn't any rotations.

avatar image fabianzaf · Aug 31, 2012 at 10:33 PM 0
Share

Oh my you're right, either way it lets me do something I wanted in an experiment. Thank you for your help!

avatar image fabianzaf · Aug 31, 2012 at 10:36 PM 0
Share

What I can do is programmatically set the $$anonymous$$ax Angular Velocity with Rigidbody.maxAngularVelocity inside onCollisionEnter then on exit I can set it back to where it used to be.

avatar image ScroodgeM · Aug 31, 2012 at 10:39 PM 0
Share

freeze rotation for your object only. you can do it programmatically (see below) or in rigidbody's properties

avatar image fabianzaf · Aug 31, 2012 at 10:47 PM 0
Share

Your method is probably more elegant, I'll mark your answer as correct

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

edit a variable as a result of a collision 0 Answers

Remove objects if 3 or more of them are colliding 0 Answers

How to destroy the cube which I selected with the arrow key 2 Answers

Why is my object getting stuck in the edge of other objects? 2 Answers

Jumping on top of an enemy problem 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