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
2
Question by Jordos · Oct 11, 2010 at 11:47 AM · rotationrigidbody

Best way to rotate a physics-object based on input

I am trying to rotate a certain object which has a rigidbody and some colliders. The rotation is based on user input and must be applied directly and always the same (i.e. it should not be influenced by other physics objects).

What I tried:

  1. Make the object kinematic and change it's rotation every frame -> fail, because of tunneling
  2. Make the object kinematic and change it's angular velocity every frame -> fail, kinematic objects cannot have velocity (that is weird, because this is the way I do it in other engines, like Box2D)
  3. Keep the object dynamic (not kinematic) and change it's angular velocity every frame -> fail, because other objects have influence on the final rotation.
  4. Attach a configurable joint to it and change it's target rotation every frame -> fail, because other objects have influence on the final rotation.
  5. Attach a configurable joint to it and change it's angular limits every frame -> fail, because other objects have influence on the final rotation.
  6. Make the object kinematic, attach a configurable joint to it and change it's target rotation every frame -> fail, because the joint drivers don't work on kinematic objects.

So, I'm kinda out of ideas here. I hope someone has a nice suggestion?

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

Answer by Mystyr Nile · Oct 11, 2010 at 09:40 PM

Here's a JavaScript I made that should work when attached to a kinematic rigidbody.

var speed=90; //The above defines the speed at which this object will rotate when the //x axis is not zero.

function Update(){ var x=Input.GetAxis("Horizontal")*Time.deltaTime*speed; transform.Rotate(0,x,0); } //The above rotates this object at the speed of "speed" degrees per //second in the direction pressed.

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 Jordos · Oct 12, 2010 at 07:22 AM 0
Share

That's the same as changing the rotation directly. The problem is objects fall through the object that is rotated, when the angle is big enough (called tunneling).

avatar image Mystyr Nile · Oct 17, 2010 at 08:23 PM 0
Share

I . . . don't understand the concept of tunneling. Could you explain more deeply?

avatar image
0

Answer by dissidently · Dec 20, 2010 at 05:36 PM

You can place the object on a unique layer, this way no other physics objects will have influence over it if you choose to turn that off in that layer. Then do as you please with it.

If you need it to feed information about it's position to other objects for their physics, create a dummy object in the right layer for objects you want to influence, turn off the dummy object's rendering, but add joints or nest objects or whatever you need do, then get the transform information regularly from your player controlled object and pass it to the dummy object as regularly as needed.

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

No one has followed this question yet.

Related Questions

Rotating a rigid body to face left or right smoothly 4 Answers

Rotating sphere with rigidbody attached 1 Answer

How can I rotate and move a cylindrical rod from one side with respect to other side? 1 Answer

why can't my Rigidbody not rotate on slopes? 1 Answer

c# problem with limiting rotation (with rigidbody) 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