• 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 unity_PfHgO2CCqrgBHA · Jun 20, 2019 at 10:27 AM · rotationchildrencamera-lookminimap

Object rotation as a children of the main camera

Hello,

I have a problem with the rotation of an object (simple arrow for the minimap). The object is attached to the camera as a children, so it takes the movement and the rotation from there. What i would like to do, is to make the object stop rotating up and down only left and right.(I tried with Rigidbody freeze rotation on X, but it`s not working) I would attache the arrow as a children to the FPSController, but I`m using Cinemachine in this scene so I need to attache to the main camera. thank you for your answers in advance! Have a nice day, Tamas

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 highpockets · Jun 20, 2019 at 10:39 AM

You could just point in the same direction constrained to the plane you want via Vector3.ProjectOnPlane().

 Vector3 direction = Vector3.ProjectOnPlane(Camera.main.transform.forward, Vector3.up);
 Quaternion rot = Quaternion.LookRotation(direction, Vector3.up);
Comment
Add comment · Show 7 · 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 unity_PfHgO2CCqrgBHA · Jun 20, 2019 at 10:51 AM 0
Share

@highpockets thank you for your answer, I put this lines of code in a script on the object, but unfortunately this changes nothing.

avatar image highpockets unity_PfHgO2CCqrgBHA · Jun 20, 2019 at 10:53 AM 0
Share

@unity_PfHgO2CCqrgBHA are you passing the rotation to the arrow object?

Probably best you upload your script

avatar image unity_PfHgO2CCqrgBHA highpockets · Jun 20, 2019 at 11:06 AM 0
Share

I have a dolly track in my scene, a vcam witch is following the track (it`s a simple walkthrough) and I have a $$anonymous$$inimap to show the user where is he exactly in the apartment. you can look around using the mouse, but can`t control the movement of the character. what i want is to rotate the arrow as you look around (if you look at the door the arrow must face to the door) right now works fine, when i move my mouse to the right the arrow turns right, if look to the left, turns left, but the problem is when i look up, or down the arrow follows the camera, and i don`t need that . I hope that this way is more understandable, I`m quite new in unity without any programming background, so I don`t know where to put your question, sorry

Show more comments

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

142 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

Related Questions

rotate a object around the x axis like other object... stucks at 90 degrees 2 Answers

iTween - rotation messed up on children objects 4 Answers

Attempting to emulate unity editor style mouse look. Is jerky for some reason. 1 Answer

Quaternion.LookRotation is making my object rotate around a point? 1 Answer

Instantiate GameObject to specific position on the Parent 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges