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 /
  • Help Room /
avatar image
1
Question by Garsun · Sep 02, 2016 at 11:54 PM · objectvector3move

How to move object a from in front of object b to in front of object c and transfer orientation?

Learning vector arithmetic... I have two fixed cubes in my scene. Each cube has a different position and orientation ( Rotation ). I have a cylinder a certain distance from the center of the first cube's front Z axis face.

I would like to place the cylinder in front of the second cube's Z axis at the same distance and with the same orientation that it currently has in front of the first cube.

For a more visual for example, let's say I have my left hand palm up with a marble floating 3 inches above the center of the palm. I placed my right hand 1 foot from my head with the palm facing my face. I'm looking for the calculation that would move the marble from my left hand to my right hand so that the marble is between my right palm and my face 3 inches from the palm.

Obviously something like:

`Cylinder.transform.position=Cylinder.transform.position - CubeA.transform.position + CubeB.transform.position;

Won't to do the trick...

Some examples or pointers to resources would be appreciated.

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 doublemax · Sep 02, 2016 at 11:56 PM 0
Share

$$anonymous$$aybe try to explain it with pictures ins$$anonymous$$d of describing it with words only.,

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Garsun · Sep 03, 2016 at 01:54 AM

@doublemax alt text Here's a two dimensional version. I change the object shapes for clarity (cylinder into a half cylinder and the cube into a shape square). The objective is to move the cylinder on the left and position it where the cylinder on the right is relative to cubeA and CubeB. Of course I need it to all work in three dimensions. I think by working with transform.rotation and transform.position it can be done, unfortunately I'm having difficulty coming up with an approach. I was sort of hoping there was a built in function that would do it for me since the parent and child relationships depend upon this type of manipulation

PS: whenever I signe into my account, both the forom and answer websites breaks with a "too much recursion error". I did not think anything was being posted until I received a notification email from your post. My apologies if anything is getting duplicated or I don't see a response. I'm not sure how to fix the issue.


example-one.jpg (46.5 kB)
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 doublemax · Sep 03, 2016 at 10:47 AM 0
Share

If the cylinder is a child of the cube it's relatively simple, you just have to copy Transform.localPosition and Transform.localRotation.

Unfortunately i couldn't figure out the math to do this when it's not a child.

I hope someone else can step it and answer this, because i'd like to know myself now. (Ideally with explanations :) )

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

77 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

Related Questions

Why does my object's position change when I rotate it? 0 Answers

Object moving problem 0 Answers

What is the best way to script a trigger that moves a object from point a to point b in C# (unity 5) 0 Answers

HOW TO MOVE A OBJECT TO ANOTHER OBJECT SMOOTHLY NOT INSTANTLY? 0 Answers

How do i get the angle of two Vector 3's? 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