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 eeveelution · Feb 22, 2015 at 04:27 PM · 2drotationrotateclippingclip

(2D) How to make kinematic rigidbodies rotate without clipping?

Hey! I just started learning Unity, and I ran into a problem. I can't really find the answer myself, but if it was asked before, sorry. So I'm making a 2D game where you need to rotate the level to make a ball fall into a hole, but you can only see in a very small area around you. I'm just making a prototype thing now, and I have the ball and lighting done, along with a reset button (R). Now I'm trying to get the platform to rotate properly when I press A or D. The rectangle I'm trying to rotate is a child of the "Level" empty gameobject. The Level has to stay in one place and should only be able to rotate. What I have now kind of works, but because it's not a rigidbody (which prevents it from falling), it slightly clips through the ball. here's the code: #pragma strict var OriginalRot = transform.rotation; function Start () {

 }
 
 function Update () {
     if(Input.GetKeyDown(KeyCode.A)||Input.GetKey(KeyCode.A))
     {
         transform.Rotate(Vector3.forward, 2);
     }
     if(Input.GetKeyDown(KeyCode.D)||Input.GetKey(KeyCode.D))
     {
         transform.Rotate(Vector3.forward, -2);
     }
     if(Input.GetKeyDown(KeyCode.R))
     {
         transform.rotation = OriginalRot;
     }
 }

The clipping isn't very serious, but it can be a major problem later and I want it out of my way now. I tried making it a rigidbody, but gravity made it fall. I made it kinematic to stop if from falling, but then the rigidbody's addtorque doesn't work. What should I do to make it not clip, be able to rotate and stop when I want to, or at least have some inertia stopping it, while not being affected by gravity?

Any help is well appreciated! thanks in advance :D

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

Answer by bundibundi · Apr 28, 2015 at 04:40 AM

Try Rigidbody.MoveRotation

http://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

how to rotate 2d obj on android 1 Answer

rotate object that has FixedJoint2D 1 Answer

Its this possible? 1 Answer

[Help] Object flips around when using transform.Rotate 3 Answers

Rotating a 2D GameObject on Z regardless of the distance. 2 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