• 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 Kerge · Oct 31, 2012 at 03:18 AM · characterrotatearoundheadvibrate

What is wrong with my RotateAround?

Hey all!

I wrote this script and i attached to my camera:

 void Start()
 {
     if (rigidbody)  rigidbody.freezeRotation = true;
 
     cursorPosition = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
     cursorDiff = new Vector2(0.0f, 0.0f);
 }
     
 void UpdateCursorDiff()
 {
     cursorDiff = cursorPosition - new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
     cursorPosition = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
 }
 
 void UpdateLookDirection()
 {
     characterHead.transform.RotateAround(new Vector3(0.0f, 1.0f, 0.0f), -(cursorDiff.x * Time.smoothDeltaTime) * cursorSensitivity);
     characterHead.transform.RotateAround(new Vector3(1.0f, 0.0f, 0.0f), (cursorDiff.y * Time.smoothDeltaTime) * cursorSensitivity);
     characterHead.transform.eulerAngles = new Vector3(characterHead.transform.eulerAngles.x, characterHead.transform.eulerAngles.y, -90.0f);
 }
 
 void Update()
 {
     UpdateCursorDiff();
     UpdateLookDirection();
 }

But my character's head vibrates and when i move my mouse his head turns back to its original state... Can anyone help me?

(Sorry for my bad english! I am hungarian.)

Comment
Add comment · Show 2
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 Fattie · Oct 31, 2012 at 08:42 AM 0
Share

FWIW there is a massive discussion of this sort of thing on unityGE$$anonymous$$S.com - quaternions etc.

Your English is incredibly better than my Hungarian :-)

avatar image Kerge · Oct 31, 2012 at 09:36 AM 0
Share

Ohh o.O Thanx guys! I tought $$anonymous$$ouse X & Y returns the current mouse position not the difference :P

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by AeonIxion · Oct 31, 2012 at 08:19 AM

I'm not sure, but I'm guessing it's because you use Input.GetAxis("Mouse X"). Mouse X returns the movement of your mouse's x since the last frame. So if you don't move your mouse, it returns 0.

Unless you changed something in the Input inspector of course....

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 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

Related Questions

Replacing object: first object not completely destroyed? 0 Answers

Using the head look controller as a method to keep ship level with ground. 1 Answer

GUI Over AI characters 1 Answer

Display name on my character 2 Answers

Character Interface Change (Help) 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges