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 sr388 · Oct 06, 2014 at 03:54 PM · camerarotationvector3third-person

Problem with the rotation of camera in third person

I am currently creating a third person game where the character can manipulates gravity like in gravity rush, so you can walk in every surfaces where you aim like in the ps vita game. To do that I use a ray to know the normal of the surface where the player aim, so I change the rotation of the character, taking in acount that normal, and apply force to its rigidbody in that direction.

The problem is the rotation of the camera around the player in Y axis when you are in any surface different from the ground, because normally the camera rotate around the y axis , but when you change of surface it is not the same axis to rotate the camera, for example and inclined plane where the normal of the player is for example (0.6,0.3,0.7) so the camera has to rotate taking in account the normal or the transform.up of the character. In adition, when the character is in a new surface the camera rotates with him, so both have the same rotation. Maybe I don't explain properly, sorry for that

I think that I have to use a cross product of vectors but I don't get the right form, so I need a little help.The code that I use for the rotation of the camera around Y axis is:

transform.rotation=Quaternion.euler(0,mousedegress,0)

This code logically only works currently in the Y axis, so I have to modify it to work in any surfaces.

Thanks 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
0

Answer by robertbu · Oct 06, 2014 at 03:55 PM

We need to see more of your code for a exact answer, but here are three approaches:

Use Quaternion.AngleAxis() for your rotation, and use transform.up for the axis.

Use an empty game object as a parent, and assign transform.localRotation for the rotation. You would rotate the parent game object. The child will always have the same local relationship to the parent, so the rotation will work.

If you are simply rotating around, you can use Transform.Rotate(). The default usage is a local rotation, so 'transform.Rotate(0,someDelta,0), will rotate around the correct axis.

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 sr388 · Oct 06, 2014 at 07:39 PM 0
Share

Ok I just have changed my code line to transform.Rotate(0, lookAngle, 0); , which I already tried it but I didn't adjust the velocity of rotation, so when I played it the camera just rotate all the time with out control because this value was too high. So thank you robertbu, I am closer to end the control of the character.

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

2 People are following this question.

avatar image avatar image

Related Questions

Keep camera at certain distance from character when rotating 3 Answers

Get a child object to rotate a parent to the cameras direction -1 Answers

Player rotation = Camera Rotation 0 Answers

RTS Camera movement wrong after rotation 1 Answer

How do i lock the position of the camera above the player relative to the origin point? 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