• 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 arvzg · Apr 26, 2014 at 09:16 AM · camerarigidbodythird-personfixedupdate

Jittery thid-person camera follow behaviour

I'm writing a controller script for a floating UFO-like ship that behaves somewhat like a helicopter, but is not affected by gravity.

The control script for the ship looks like this:

     void FixedUpdate()
     {
         vertical = Input.GetAxis("Vertical");
         horizontal = Input.GetAxis("Horizontal");
         forward = Input.GetAxis("Forward");
 
         rigidbody.rotation = Quaternion.Lerp(rigidbody.rotation, Quaternion.LookRotation(myCamera.forward, myCamera.up), Time.deltaTime * rotateSpeed);
         rigidbody.AddForce(transform.up * vertical * verticalSpeed);
         rigidbody.AddForce(transform.right * horizontal * horizontalSpeed);
         rigidbody.AddForce(transform.forward * forward * forwardSpeed);
     }

Which is simply:

  • Space/Ctrl to move the ship up and down

  • W/S to move the ship forwards and backwards

  • A/D to strafe the ship left and right.

And I have a Third person camera object (from the Sample Assets Beta package from the Asset store) following and tracking my ship.

The ship controls perfectly fine, however when viewing the game from the Game view, Forwards, Backwards, and strafing left and right seems to work fine, however rotating the ship seems to cause the ship to look 'Jittery'. As far as I can see the jitter doesn't happen on the ship, but on the camera, as viewing the ship rotate in the Scene view doesn't look like it's jittering.

As you can see, the Rotation is happening in FixedUpdate. The Third Persona camera prefab has an option to set the Update type for FixedUpdate or LateUpdate. I have chosen FixedUpdate as it seems to work better (LateUpdate has even worse jittering)

Any ideas, what can I try here to try and solve this?

Comment
Add comment · Show 1
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 arvzg · Apr 26, 2014 at 08:20 AM 0
Share

I'd also appreciate any comments for the way I've implemented the controller script - is this an O$$anonymous$$ way to do this? Is there a better way? The script does not appear in the Profiler at all when running the game, so I assume it is not not a terrible algorithm

0 Replies

· Add your reply
  • Sort: 

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

20 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

Related Questions

Camera update when tracking physics controlled object 0 Answers

Addforce to ball in camera position 0 Answers

Changing Free Look Camera Target At Runtime 2 Answers

Third-person camera snaps to 270 degrees on activation 1 Answer

Rigidbody spins out of control 0 Answers

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