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 Kalbytron · Sep 09, 2013 at 09:25 PM · cameratransformtrigger

how to change orbit camera rotation when player runs into trigger box

I have recently created an object teleporter script that that teleports the player to specific location and it changes the player's rotation if specified. Also, I want the script to tell the main camera to change it's rotation when the player touches the trigger box. I have tried using:

Camera.main.transform.rotation = Quaternion.Euler(newRotation)

but nothing happens. (newRotation is a vector3 var)

Another thing is that earlier in this project, I accidently deleted the pre made Main Camera that comes with the start of the project. So I tried remaking the main camera by spawning one, naming it "Main Camera" and tagging it respectively like the original. I was wondering if this would be part of the problem whether Camera.main is not responding to this.

Comment
Add comment · Show 3
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 getyour411 · Sep 09, 2013 at 09:50 PM 0
Share

You could test that theory by declaring the camera with public Camera theCamera and then drag your Camera in the hierarchy into that public reference point, then change Camera.main to theCamera. I doubt that's the problem if you recreated/retagged though. Do you have any code on your player's movement control scripts that might be clamping or locking the camera?

avatar image Kalbytron · Sep 09, 2013 at 10:17 PM 0
Share

Not in the player movement script but in my orbit camera control script(attached to main cam). All horizontal movement is free from clamping, and vertical movement is clamped to +-60 degs(adjustable). The camera is not locked and it can be freely controlled by the player. The teleporter script is suppose to tell the main camera what angle to rotate to when the player runs into the trigger. That is why I'm using Camera.main which is suppose to be assigned to the first camera automatically. I believe dragging the camera to the public variable is too many steps.

avatar image getyour411 · Sep 10, 2013 at 03:44 AM 0
Share

I suggested the public Camera reference part just to test your suggestion of a possible corrupt Camera.main (the drag/drop would bypass that shortcut) but I doubt that's the issue. When I can't find my logic error, I usually fallback to

 Debug.Log("Rotating Camera.main to " + newRotation);

just to ensure I'm getting to the suspect bit of code and that my variable contains the value I'm expecting.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kalbytron · Sep 10, 2013 at 07:39 AM

Thanks for the feedback guys, but I have already figured it out on my own. All I had to do was write:

Camera.main.SendMessage(function name, rotation values, don't required feedback)

This worked out for rotating the camera to a new angle after teleporting.

Comment
Add comment · 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

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

move camera when it collides with a trigger 1 Answer

Move JoyStick Together With Camera 1 Answer

enter a trigger to access other camera? 1 Answer

Active camera on Start 1 Answer

Camera distance from mesh not center 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