Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 fluxhackspro · May 07, 2018 at 06:38 PM · rotatepivot

Not rotating around the correct pivot point?

Hello in my movementscript im trying to rotate the player when D or A is pressed accordingly. I set up a rotationpoint and made sure it rotates around that point. But the player still rotates around an other point and it makes the player slide around on the ground like the moon around earth. If i switch between pivot and center it is in the same place! here is my code i dont know what im doing wrong:

 //ROTATE
             if (Input.GetKey (KeyCode.D)) {
                 transform.RotateAround(RotatePoint.transform.position, Vector3.up, 2);
             }
 
             if (Input.GetKey (KeyCode.A)) {
                 transform.RotateAround(RotatePoint.transform.position, -Vector3.up, 2);
             }
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
0
Best Answer

Answer by fluxhackspro · May 07, 2018 at 10:38 PM

Thank you @Vicarian for pointing out that im getting the charactercontroller speed from A and D as well from Input.GetAxis!

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 Vicarian · May 07, 2018 at 06:58 PM

Usually if you're rotating an object, the rotation is done in the object's local space. By using RotateAround in that manner, you're telling your object to rotate around a fixed axis in world space. So, let's say you have an rotation point at the origin <0, 0, 0>, and your object is at <1, 0, 1>. As the object rotates with RotateAround, its position will update with respect to the origin, so essentially its path will draw a unit circle about the origin parallel to the xz plane.

To account for the objects position in world space, simply use transform.Rotate(Vector3.up, 2);

Comment
Add comment · Show 12 · 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 fluxhackspro · May 07, 2018 at 07:00 PM 0
Share

So what rotate method should i use ins$$anonymous$$d? Before i change to this method i used this but it did the same: transform.eulerAngles = transform.eulerAngles + new Vector3 (0, -90, 0) 2 Time.deltaTime;

avatar image Vicarian fluxhackspro · May 07, 2018 at 07:05 PM 0
Share

That calculation probably isn't correct. Simply use transform.Rotate(Vector3.up, 2);

avatar image fluxhackspro Vicarian · May 07, 2018 at 07:53 PM 0
Share

it STILL rotates around like i told you earlier.

Show more comments

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

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

Related Questions

Rotating GUI issues, issues with X,Y cords. 1 Answer

Trying to rotate player, how? 0 Answers

Arbitrary rotation around a point works except when up flips? 1 Answer

Rotating Cuboid Around Pivot 2 Answers

Camera rotation around player while following. 6 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