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 Carkey · Jan 07, 2013 at 01:05 AM · rotationmovementrigidbodyconstraints

Player model Rigidbody keeps falling upsidedown

Hi,

I've seen some questions like this on here but haven't been able to find an answer that works.

I have a "player character" (so far it's just a cube) that is a rigidbody and I do transform.Translate based on Input.GetAxis().

I have the rigidbody constrained to only move in the X and Y and have the rotation constrained to the Z axis, my problem is that my cube (more of a tall cuboid) can fall over when I move up and down the ramps and platforms I've made.

I've tried artificially constraining the player in the Z rotation such as:

 Vector3 rot = transform.eulerAngles;
         
         if(rot.z > 45f && rot.z < 350f)
             rot.z = 45f;
         
         transform.eulerAngles = rot;

I do this on LateUpdate() but have tried it on Update() as well with the same result, which is that if it rotates past 45 degrees, I make it equal 45 degrees but then it just stays there, the physics engine never seems undo it from this.

I'm not entirely sure how the physics engine works but why wouldn't it make my cube fall back below 45 degrees?

Any help would be greatly appreciated!

Thanks

P.S. I have the < 350f check in there because when the cuboid is moving on the flat the angle seems to go between 355ish - 0.5ish.

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

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

8 People are following this question.

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

Related Questions

Is it possible to constrain an object's rotation in worldspace? 2 Answers

How to make a RigidBody not go into ground when tilted foward? 2 Answers

How does one constrain rotations of a CharacterController without a Rigidbody? 0 Answers

Rigidbody constraints not working with parent/child relationship 2 Answers

Rotate object towards target without influencing AddForce 0 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