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 Gamehusky · Jul 27, 2016 at 07:16 PM · rotationrigidbodyquaternions

Rigidbody along with up-vector

I've been trying to solve this for the past few days. I've been trying to find a good solution to this problem but I cant find any. I'm also new to to Rigidbodies in Unity so any help is appretiated!

Okay, so the thing is I want a RigidBody (Player and almost everything else) to move along different curves in my game.

When working only with the transform, the following code works just fine:

(I'm using my own function here to find out the up-vector at the transform's position)

 // Set the transform.up vector to the curved plane up-vector
 transform.up = GridUp (transform.position);

But when trying to modify the RigidBody rotation to the up-vector, the result is wierd. Also when reading other posts one should not chnage the rigidbody rotation and position directly, but instead use the AddForce() and AddTorque() funcions.

My questions is: How do I rotate a RigidBody to a specific up-vector, and keep the functionality of the RigidBody physics?

alt text

Example picture: Moving a rigidbody box along a slope (Red arrow) with rotation around the slope y-axis (Green arrow)

rigidbody.png (17.2 kB)
Comment
Add comment · Show 1
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 Gamehusky · Jul 30, 2016 at 01:36 PM 0
Share

Anyone have a clue on how to solve this?

2 Replies

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

Answer by Gamehusky · Aug 23, 2016 at 09:11 PM

I found the answer in another thread:

http://answers.unity3d.com/questions/10425/how-to-stabilize-angular-motion-alignment-of-hover.html

Works like a charm!

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
avatar image
0

Answer by matthrewp · Jul 30, 2016 at 02:51 PM

Use Rigidbody.AddTorque:

 using UnityEngine;
 using System.Collections;

 public class Example : MonoBehaviour {

     //apply this script to the object you want to turn
     Rigidbody rbody;
     void Start()
     {
         rbody = GetComponent<Rigidbody>();
     }
     void Update ()
     {
         rbody.AddTorque(new Vector3(0, 1, 0));
         //play with the X, Y, and Z values to get the rotation you want
     }
 }

Hope this can help!

Comment
Add comment · Show 1 · 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 Gamehusky · Aug 23, 2016 at 07:20 PM 0
Share

Thank you for your answer! But the problem is how I should use AddTorque to stablize the RigidBody to a specific vector up direction.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to wall-walk? 2 Answers

smoothly rotate my rigidbody with CapsuleCollider to facing the fall direction 0 Answers

Rigidbody spins out of control when colliding into corner 0 Answers

Can i Move/Rotate triggers without Rigidbodies? And other collider questions. 3 Answers

Pysics not working as expected 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