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 Ranger_DeVill · Oct 27, 2020 at 06:13 PM · rotationrigidbodyaxis

Rotating rigidbodies with moveRotation along external axis

Hello, I'm in a process of programming a robotic arm in Unity. I've created 3D model and would want to move them but with a caveat that if (for example) I rotate the base, the arm rotates as well. The catch? I wanted Unity to handle collisions for base objects (like cubes, spheres, etc.). My goal is to have objects which I could pick up and let go. At first I've tried using " transform.rotate" in order to move the arm's joints. It all seemed great, as I had parented the objects from base - up and whenever I " transform.rotate" the base, the rest of the robotic arm rotates as well. But then I was told that one should use rigidbodies for collisions and this is where things have started to fall apart. First thing is that when I use rigidbodies, they no longer rotate when parented (when using “transform.rotate”). Second, when I use “transform.rotate” I'm able to phase into objects. I guess that’s since this function works as a teleport of sort. And so, I wanted to use “Rigidbody.MoveRotation”. This works, but only for one of the elements. They, of course, don't move when parented, so I've thought that maybe I could use “Rigidbody.MoveRotation” to rotate each of the arm's elements along their "lower tier" element's axis (see tiers below)


base – boom – arm - gripper


but I'm stuck at getting it to work. Am I understanding correctly, that “Rigidbody.MoveRotation” applies rotation ONLY along the local rotation axis?

I paste my code below, but I don't think if will be of any use:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Manipulator_movement : MonoBehaviour
 {
     public GameObject Obrotnica;
     public GameObject Wypad;
     public GameObject Ramie;
     
 
     public float myInput;
     public Vector3 m_EulerAngleVelocity;
 
     public float tempRotationOfObrotnica;
     public Quaternion tempRotationOfObrotnicaQ;
     public Quaternion GG;
     
     // Start is called before the first frame update
     void Start()
     {
         GG = Wypad.transform.rotation;
     }
     
     void Update()
     {
     
         if (Input.GetButton("Right_Shoulder_Trigger") || Input.GetButton("Left_Shoulder_Trigger"))
         {
             Debug.Log("LJH: " + Input.GetAxis("Left_Joy_Horizontal") + "LJV: " + Input.GetAxis("Left_Joy_Vertical") + "RJH: " + Input.GetAxis("Right_Joy_Horizontal") + "RJV: " + Input.GetAxis("Right_Joy_Vertical"));
         // this is for controller support debugging
         }
         else 
         {
             //obrotnicaAngleSpeed = 0;
         }
 
 
     }
 
     void FixedUpdate()
     {
         Rigidbody temp_rigidB_Obrotnica = Obrotnica.GetComponent<Rigidbody>();
         Rigidbody temp_rigidB_Wypad = Wypad.GetComponent<Rigidbody>();
 
         Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * myInput * Time.deltaTime);
         temp_rigidB_Obrotnica.MoveRotation(temp_rigidB_Obrotnica.rotation * deltaRotation);
 
         tempRotationOfObrotnica = temp_rigidB_Obrotnica.transform.rotation.eulerAngles.y;
         //tempRotationOfObrotnicaQ = Obrotnica.transform.rotation;
         tempRotationOfObrotnicaQ = Quaternion.AngleAxis(Obrotnica.transform.rotation.y,new Vector3(0,Obrotnica.transform.rotation.y,0));
         //temp_rigidB_Wypad.MoveRotation(Obrotnica.transform.rotation);
         temp_rigidB_Wypad.MoveRotation(GG);
         //temp_rigidB_Wypad.MoveRotation(temp_rigidB_Wypad.rotation * tempRotationOfObrotnicaQ);
         //Obrotnica.transform.Rotate(0f,obrotnicaAngleSpeed*Time.deltaTime,0f,Space.Self);
         //Obrotnica.transform.ro
 
     }
 }

Maybe there’s a different way to do it and I'm just to blind to see it?

I'd be grateful for any help you guys can spare. Thanks in advance.

Cheers, Rafał

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

226 People are following this question.

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

Related Questions

How to rotate the axis of a 3D GameObject 1 Answer

Aircraft Banking Rotation Problem 2 Answers

How to lock X rotation; broken script 0 Answers

Is it possible to swap my x Axis and y Axis on a rigidbody2D? 1 Answer

Get localScale depending on rotation 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