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 Dubious-Drewski · Aug 15, 2013 at 05:59 AM · camerarotationcharactercontrolleryaw

Character Controller removes possibility of camera yaw?

This is probably a silly question, but I can't figure it out. I want my character controller camera to rotate around the Z axis, AKA I want it to "Yaw".

 theCamera = GameObject.Find ("Main Camera");
 theCamera.transform.localRotation = Quaternion.Euler(0f,0f,45f);

The rotation is applied, because this line tells me so:

 print(theCamera.transform.rotation.eulerAngles);

Yet the camera physically does not respond to my code. It does not rotate. I know that it must be the Character controller which is stopping this. How can I get around this?

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 robertbu · Aug 15, 2013 at 06:31 AM 1
Share

It is not the character controller. I just ran a quick test, and I had no problem. Note I used:

 Camera.main.transform.localRotation = Quaternion.Euler(0f, 0f, 45f);

But since your code did not generate a null reference exception, I assume the GameObject.Find() is working.

Do you have any scripts on the camera? Smooth Follow, or $$anonymous$$ouse Orbit, or something else?

avatar image Dubious-Drewski · Aug 15, 2013 at 07:09 AM 0
Share

Thank you for replying. I must be missing something though.

I started up a new scene, added a default First Person Controller and added this script to it:

 public class test : $$anonymous$$onoBehaviour {
     void Update () {
         Camera.main.transform.localRotation = Quaternion.Euler(0f, 0f, 45f);
     }
 }

The camera was still perfectly upright; the code did not work. It appears to be caused by the $$anonymous$$ouselook script attached to the camera. If I disable it, the code works.

So it's specifically that code which is doing it. I'll have a look inside to see if I can solve it. Could you (or someone) please help?

avatar image Dubious-Drewski · Aug 15, 2013 at 07:17 AM 0
Share

Ahha! It's the code on line 53 in the $$anonymous$$ouselook Script. It sets the Z rotation to 0 every frame.

Now I have a different problem. I need to take control of the rotation, but I'm using C# and $$anonymous$$ouselook is Java. I heard it's a nightmare to pass variables between these two. Is this true?

avatar image robertbu · Aug 15, 2013 at 09:35 AM 1
Share

You have to get the compilation order right. For example if you drop your Javascript in StandardAssets, then you should not have trouble accessing the class from C#. $$anonymous$$ore information on compilation order can be found here:

http://docs.unity3d.com/Documentation/$$anonymous$$anual/ScriptCompileOrderFolders.html

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

15 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

Related Questions

Third person camera; player rotation. 1 Answer

Camera lock on enemy 0 Answers

player rotate to camera direction but not moving in it's direction 0 Answers

easing camera rotation after mouse up? 0 Answers

Is there a way to make a Character Controller stop instead of move over obstacles?? 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