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
0
Question by Cancler · Oct 28, 2015 at 01:20 PM · unity 5cameracamera-movementlerpcamera rotate

Tilting a camera around an object

My goal is to have a central object where the camera will tilt to the left and right of it while also rotating to get a view of the object using the A and D keys. I've tried this a few ways so far, just rotating the camera (went horrible), lerping (went better but was kind of hard to wrap my head), and move towards (didn't have the smooth effect of lerping).

I also want the camera to snap back into its original location after the A or D key is released. So I'm just hoping to get a better understanding of what the best thing I can use here is. Been working on this for like 2 days now with sub par results.

alt text

29usmw1.png (23.8 kB)
Comment
Add comment · Show 4
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 Paulo-Henrique025 · Oct 28, 2015 at 01:25 PM 2
Share

Have you tried to change the pivot of the camera? By parenting it to a empty object located at the same position of your "parent object".

avatar image Cancler Paulo-Henrique025 · Oct 28, 2015 at 01:31 PM 0
Share

Do you mean I should create an empty and attach the camera to that and then just rotate the empty? Sorry pretty tired atm

avatar image ODINKONG · Oct 28, 2015 at 03:45 PM 0
Share

Are you just trying to get the camera to orbit around an object like in a typical 3rd person game? I would say make a copy of the mouse orbit script that comes with unity and try modifying that. If you don't want to write it in java which that script is written in then here is the core functionality of an orbit cam in c #

public Transform target;

Vector3 position;

Quaternion rotation;

float y;

float x;

public float distance = 5f;

public float xSpeed = 250.0f;

public float ySpeed = 120.0f;

public float y$$anonymous$$inLimit = -20f;

public float y$$anonymous$$axLimit = 80f;

Update(){

transform.position = position;

transform.rotation = rotation;

x += Input.GetAxis("$$anonymous$$ouse X") * xSpeed *1.5f*Time.deltaTime;

y -= Input.GetAxis("$$anonymous$$ouse Y") * ySpeed *1.5f*Time.deltaTime;

y = clampAxis(y, y$$anonymous$$inLimit, y$$anonymous$$axLimit);

rotation = Quaternion.Euler(y,x,0);

position = rotation * new Vector3(0,1,-distance) + target.position;

}

float clampAxis (float axis, float $$anonymous$$, float max){

 if (axis < -360) {

     axis += 360;

 }

 if (axis > 360) {

     axis -= 360;

 }

 return $$anonymous$$athf.Clamp (axis, $$anonymous$$, max);


}

avatar image Statement · Oct 28, 2015 at 06:06 PM 0
Share

So it looks like you want to follow the contour of a box? Or do you just want to rotate in a half circle?

At first glance it looked like you wanted to make some weird camera for sitting behind cover, peeking up behind and at the sides of a wall, but that's not it, is it?

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Lerp Not working 1 Answer

help with switching camera 0 Answers

Using DampSmooth in EulerAngle is affecting the Position.Z value of the gameObject. 0 Answers

Camera Roll/Headbob? 0 Answers

How to recreate the Silent Hill 1 camera style? 0 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