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 hurr_durr · Jan 03, 2019 at 10:41 PM · camera followcamera movement

Specific camera coordinates based on players coordinates.

So i want to make my camera always be y (y coordinate) units over my player and xz (x and z coordinates) units offset from players y axis, while still having this piece of script work:

if (Input.GetAxisRaw("Mouse ScrollWheel") > 0) { transform.LookAt(target.transform.position); transform.RotateAround(target.transform.position, Vector3.up, 20 * Time.deltaTime * 10f); // A = 1; } if (Input.GetAxisRaw("Mouse ScrollWheel") < 0) { transform.LookAt(target.transform.position); transform.RotateAround(target.transform.position, Vector3.down, 20 * Time.deltaTime * 10f); //A = -1; } can someone help me?! I can already lock the y coordinate, but getting x and z to work is impossible for me.I also can't just make the camera child to the player as the player is a rolling ball, and the camera totally freaks out when it starts to roll. I hope i explained what i want to do enough and if not just ask and I'll try to clarify it a bit more.

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 Shaolin-Dave · Jan 03, 2019 at 11:11 PM

The way I usually have the camera follow the player is by creating an empty GameObject that does only one thing: follows the player. It's not a child of the player, it just constantly updates it's transform to match the player's position (or move towards the player's position at a certain speed for camera smoothing). Make your camera a child of this empty GameObject, and it will maintain it's position/rotation in relation to the player until you tell it to do otherwise.

The "otherwise" is where you lost me. You shared some code but didn't explain at all what you're end goal is, nor is the code commented. It seems you want the camera's position to stay offset from the players, but for it's rotation to point at a different target? The method I described should not affect this.

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 hurr_durr · Jan 04, 2019 at 10:47 PM 0
Share

That's exaclly what i wanted! I tried to do i purely with code, and I didnt think tomake a "middleman" between two objects. $$anonymous$$aybe I just don't have a proper $$anonymous$$dset for now. Thank you very very much!

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

98 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

Related Questions

FPS cam for Roll -a-Ball like game 1 Answer

Camera leaning problems (Lerping) 0 Answers

Cinemachine & Playmaker 3rd person zoom 0 Answers

Slight camera stutter with Cinemachine 2D (Video inside) 1 Answer

Automatic 3rd person camera 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