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 snowconesolid · Jan 03, 2012 at 05:37 AM · cameracontrol

Getting the camera to rotate around player but not damp around them?

hey guys I have another question. I have been trying to get the camera to rotate around my player when the user holds down keys.

so for example if the user holds down the Z key, then the camera should rotate left and keep rotating until they release the key, if the user holds down X key the camera should rotate right and keep rotating around the player until they release it.

I want to do this without damping, In my camera script I disabled rotation damping, so now it only follows the player but doesnt follow their rotation and thats what I wanted. I want the user to be able to rotate the camera around the player left and right on key press.

you know very similar to most games that have this kind of camera control, for example in Zelda Wind Waker you can use the C stick to rotate the camera around link or in Monster Hunter, you can use the D-pad to rotate the camera left and right.

Iv looked all over unity, the website, answers, and the wiki (I found some mouse orbits in the wiki, but not exactly what im going for)

so far I have this code

var target :Transform ;

function Update ()

{

if(Input.GetKeyDown(KeyCode.Z))

{

transform.LookAt(target);

}

transform.Translate(Vector3.right * Time.deltaTime);

}

of course this code doesnt work, im trying to getting it going, no luck though.

thanks for any help in advance! :)

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

Answer by Winterblood · Jan 03, 2012 at 11:03 PM

Here's how I'd do it - create a dummy gameobject at the target position and parent the camera to it. Then add this to the dummy object (not the camera). The camera should then follow the player without rotating, and rotating the dummy will orbit the camera around the player.

 var target :Transform ;
 
 function Update ()
 {
     var rot : Vector3 = transform.rotation.eulerAngles;
     if(Input.GetKeyDown(KeyCode.Z))
     {
         rot.y += 45 * Time.deltaTime;
     }

     transform.position = target.position;
     transform.rotation.eulerAngles = rot;
 }
Comment
Add comment · Show 2 · 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 snowconesolid · Jan 04, 2012 at 03:16 AM 0
Share

Thanks works great, It doesnt keep rotating while holding down a key, you have to keep pressing the key to rotate however much you want, but still it works great and is how I imagined it to work. Besides I can make a couple of modifications to it.

Thanks a lot :)

avatar image Winterblood · Jan 04, 2012 at 02:08 PM 0
Share

Sorry, my bad - if you use Input.Get$$anonymous$$ey ins$$anonymous$$d of Get$$anonymous$$eyDown, it'll continue rotating while you hold the key pressed.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make camera position relative to a specific target. 1 Answer

Unity3d or Maya-style Camera navigation 5 Answers

Changing the Camera Control 2 Answers

Third Person Camera Control 2 Answers

Keyboard Controlled Overhead Camera Rotation 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