Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 tyler · Jan 12, 2010 at 12:47 PM · camera2drotation

top down 3d camera rotation question

How do you control the max amount of rotation of an object ? and / or How to you fix an 'axis' of rotation ?

Here is the example :

I have a camera looking down onto a scene, smoothly following the player. The camera is at a fixed position and rotates. How do I stop the camera rotating after a cetain amount of rotation and/or not rotate on a specifc axis. i.e I want 'north' to remain 'north' for the player and for the camera to no show too much of 'offmap'.

thanks for any help on this.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Ashkan_gc · Feb 11, 2010 at 05:18 AM

simply check the ammount of rotation of your camera and if it's larger or smaller than what you want clamp it to max or min value. your rotation is arrount the y axis i think. also you can use clamp method when you want to rotate your object and don't allow it to have a value larger/smaller than what you want. use Transform.rotate to rotate your camera. if you use other's scripts for camera movement still you can check for out of range values and change them in camera's lateUpdate function in a script.

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
avatar image
0

Answer by Nephtysis · Jan 13, 2010 at 03:20 PM

You can place the camera behind the FPC and give it the same movement script (=same speed) as the FPC. This way the camera will continue to 'follow' your character, but without the rotation at all. Do make sure that speed is equal and that the direction they're looking at is the same.

If you want to be able to 'look around' you can give the camera the MouseLook script, and I'd think you'd want to combine that with a script that says:

when "jump" is pressed, go to rotation (0, 0, 0) //=looking forward again. (For now I got:

function Update () {
if (Input.GetButtonDown("Jump"));
Transform.rotation; x = 0;
Transform.rotation; y = 0;
Transform.rotation; z = 0;
}

but I do get an error: "BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'rotation'." I know I have to add something in the first line here, still puzzling :P)

I just tried it while the camera was looking just a bit different then the FPS and it caused them to go different ways, because 'forward' meant something different to my camera then my FPS. I'm not sure this is what you want completely, but let me know what you think of this and we'll work something out here :)

(ps: not that good at scripting yet, so therefor not rightly posted here, maybe I'll have a shot at it later today and see if I can fix it)

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 Muuskii · Jul 17, 2012 at 05:17 AM 0
Share

I'm not sure if "Transform.rotation; x = 0;" is from a program$$anonymous$$g language that I do not know, but if I were a betting man I would wager that you meant transform.rotation.eulerAngles.x = 0; note the capitalization (or lack thereof) of the transform keyword. Also, realize that such an operation (iirc) is illegal in C# and would never compile.

If that's what you meant you could have replaced all three lines with "transform.rotation = Quaternion.identity;"

I don't mean to criticize someone who is just trying to help, it just seems like your suggestion has some inconsistencies.

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

1 Person is following this question.

avatar image

Related Questions

Using the accelerometer to rotate Camera 1 Answer

Backgrounds moving at different speeds? 1 Answer

Simple script to follow player only shows the camera background 1 Answer

I am getting a problem with moving and rotating a camera! 1 Answer

How can I rotate an object towards the mouse in only one axis? 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