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 Parappa · Jul 28, 2013 at 03:48 PM · rotateanglebehind

Object follow behind other object, wont stop spinning

I want to keep the yellow square in the same position relative to the purple box. So in this case to keep behind it, and it works. But the yellow square wont stop spinning around it's own Y axis

 transform.position = (player.transform.position + Vector3(0,0,-1));
 transform.RotateAround (player.transform.position, Vector3.up, player.transform.eulerAngles.y);

alt text

purple.jpg (5.9 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Jul 28, 2013 at 04:31 PM

The easiest solution is to make the yellow box a child of the purple box. You can do it in the editor by dragging the yellow box on top of the purple box in the Hierarchy. You can also do it in code:

 transform.parent = player.transform;

As for doing it separately in code, it will depend on the relationship between the orientation of the two. It appears that they both have the same rotation when following, so you might be able to just do:

 transform.rotation = player.transform.rotation;

If neither of these two solutions is a good fit, let me know. There are other more complex methods of solving this problem.

Comment
Add comment · Show 3 · 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 Parappa · Jul 29, 2013 at 10:23 AM 0
Share

I'm going to need that more complex way. If I try to get the yellow box to go off and pick up things, the purple box's movement messes it up.

avatar image robertbu · Jul 29, 2013 at 10:40 AM 0
Share

You are going to need to explain your problem better. What axis of the purple box is the yellow box following? What do you mean "go off and pick up things and how is it to aligning while it is picking up things?"

If the yellow box is going to be doing some independent movement but you still want the yellow box pointed at the end of the purple box, you can put an empty game object at the end of the purple box and make it a child of the purple box. Then have the yellow box look at it each frame:

 transform.lookAt(ObjectToLoookAtEachFRame.transform);

Note some aspects of rotation are better handled if you have the front of your object be the side that faces positive 'z' when there is no rotation.

avatar image Parappa · Jul 29, 2013 at 10:55 AM 0
Share

I'm trying to make sparks from Spyro the Dragon It follows the purple box around, but when the purple box gets close to gems, the yellow box goes off and picks them up for you.

When the purple box is not near a gem, the yellow box needs to move like it was a child to the purple box

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

15 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

Related Questions

Rotate vector around vector? 2 Answers

Transform Rotate a certain angle (and back) 2 Answers

Rotate Object to Euler Angle using Physics? 3 Answers

rotate the object only 360degree for once 2 Answers

Set rotation based on 2 points problem 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