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 KennyB6 · May 04, 2018 at 02:42 PM · cameracamera rotatecamera-lookcamera follow

Fixed-Position Camera that follows player,Fixed Position Camera that follows target.

Hello. I want to make a camera that stays in a fixed position but follows the target as the focus point, kind of like a security camera that can turn. I think it is updating the camera's transform.rotation but not sure what to set the quaternion to, or if I should be doing something similar to a raycast vector as an input for something.
Ideally, the outcome I want is the camera to be in the center of the room, above like from the ceiling, looking down and following the player around the square-ish room. I would also prefer if only the X and Y rotational axes move, with Z remaining locked at 0. Basically a fixed position camera that can swivel around to follow the player, but not rotate in the Z axis.
Thank you for any help you can offer.,Hello. I want to make a camera that stays in a fixed position but follows the target as the focus point, kind of like a security camera that can turn. I think it is updating the camera's transform.rotation but not sure what to set the quaternion to, or if I should be doing something similar to a raycast vector as an input for something.

Ideally the outcome I want is the camera to be in the center of the room, above like from the ceiling, looking down and following the player around the square-ish room. I would also prefer if only the X and Y rotational axes move, with Z remaining locked at 0. Basically a fixed position camera that can swivel around to follow the player, but not rotate in the Z axis.

Thank you for any help you can offer.

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
1
Best Answer

Answer by davidcox70 · May 04, 2018 at 02:59 PM

Use Transform.LookAt, like this: https://docs.unity3d.com/ScriptReference/Transform.LookAt.html

Comment
Add comment · Show 6 · 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 KennyB6 · May 04, 2018 at 03:32 PM 0
Share

This is definitely what I was looking for and gives a great start, thank you! Now I just need to tweak the proportions and other things. Thank you @davidcox70 and @Tespy

avatar image KennyB6 · May 04, 2018 at 03:45 PM 0
Share

What would be the best way to scale the movement? I don't need the camera to follow exactly to where the player but I just want it to turn in the direction. So if the player moves all the way to the north end of a room, I want the camera to just rotate like maybe 50% of the way northward. I tried making a new transform with position = (player.position - transform.position) / 2 but that didn't do anything, which I think is because I don't know how to initialize the new transform.

avatar image davidcox70 KennyB6 · May 04, 2018 at 03:50 PM 1
Share

There is also a slightly different function called RotateTowards. LookAt will jump directly to face whatever the target is. RotateTowards will slowly rotate until it faces the target, so a more human feel.

https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html

In terms of rotating part way, I have actually answered that very question recently. I'll see if I can find it so I can post a link....

avatar image davidcox70 davidcox70 · May 04, 2018 at 03:52 PM 1
Share

.... https://answers.unity.com/questions/1488880/follow-rotation-of-another-object-but-at-half-the.html?childToView=1488983#answer-1488983

Show more comments
avatar image
1

Answer by Tespy · May 04, 2018 at 03:04 PM

I think the LookatTarget script in Unity's built-in packages should do the trick. You may need to mess around with the rotation ranges and follow speeds to get exactly what you want, but you don't need to code anything special yourself.

In Unity, right-click your Assets folder, go to Import Package, then click Cameras. Wait for the package to load. In the import menu, click Import. Wait for the process to finish, and there you go!

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 KennyB6 · May 04, 2018 at 03:24 PM 0
Share

Thank you. When I right click the Assets folder and go to Import Package, my only option is Custom Package with the browse window. Where would the camera package be located?

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

137 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

Related Questions

How to achieve a 3rd person camera for walk on planet games? 0 Answers

make a target camera? 1 Answer

Make camera follow player and align direction 0 Answers

How can camera smoothly follow a jerky game object? (bouncing up and down) 1 Answer

How can i make the camera look up and down through keyboard keys? 2 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