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 Trild123787898 · Feb 27, 2019 at 05:14 PM · physicstransformobjectscreenjoints

Help I can not understand how to do it with joints

There are 3 objects, one of them always stands in place of the second (A) can only move along one axis, how to do that when the object (A) moves, then the object in its middle changed its position as shown in the photo ! alt text

787898.png (22.8 kB)
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
Best Answer

Answer by WarmedxMints · Feb 27, 2019 at 05:33 PM

If you want to use joints, you will need rigidbodys on the object. However, if you just want to fake it, you can simple calc a vector and rotation between the objects. If you put this script on the object in the middle and populate ObjectA and ObjectB with the left and right cubes, it will make the object in the middle face object b on it's Z axis.

 using UnityEngine;
 
 public class PositionBetweenObjects : MonoBehaviour
 {
     public Transform ObjectA, ObjectB;
 
     private void Update()
     {
         //Get the center point between the objects
         var pos = (ObjectA.position + ObjectB.position) / 2;
 
         //Get rotation between objects
         //This calc may have to be altered depend on your setup as it will set the Z direction of the object towards objectB
         var rot = Quaternion.LookRotation(ObjectB.position - ObjectA.position, transform.up);
 
         transform.position = pos;
         transform.rotation = rot;
     }
 }

Comment
Add comment · Show 5 · 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 Trild123787898 · Feb 27, 2019 at 10:53 PM 0
Share

Thanks for taking the time to help! Everything is good, only an object in the middle automatically turned 90 degrees along the Y axis

avatar image WarmedxMints Trild123787898 · Feb 27, 2019 at 11:10 PM 0
Share

Then change transform.up to transform.right or -transform.right. As I noted in the comments, the rotation may need adjusting depending on how your models are set up.

avatar image Trild123787898 WarmedxMints · Feb 28, 2019 at 12:02 PM 0
Share

so far nothing has changed! I think is (down, left) only when I am writing an error vibrating to me

Show more comments
avatar image
0

Answer by ibobtouch · Feb 27, 2019 at 05:21 PM

Try this, put a rigidbody component on your middle object, then on the two others cube, put a configurable joint component. On this component there is a "connected body", drag on your middle object. Set the X,Y,Z Motion to "Locked".

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 Trild123787898 · Feb 27, 2019 at 08:19 PM 0
Share

Thank you tried, only 2 cubes in the process but the object in the middle just stands still

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

189 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

Related Questions

attaching the hingeJoint to the desired point 0 Answers

How to fix the problem with joint! HELP I CAN NOT UNDERSTAND! 0 Answers

Help with tractor technology 0 Answers

The position of the object and its changes! Help me can not understand! 0 Answers

Dense joid joining! Help 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