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 truefictionstudios · Nov 14, 2014 at 04:58 PM · movemovingstutter

how do i stop the stuttering?

i'm trying to get an object to move a certain way. it's a spaceship i have it moving how i want it but it stutters as it moves. i want to have it point the direction that is pressed on the joystick and then the thrust button to move it forward. after the thrust is released i want it to float forward for a small distance in that direction but still be able to turn towards a different direction. any suggestions to get rid of the stuttering?

this is the code i have on my player object:

{

 public float rotationSpeed = 450;
 public float accelerationForce = 10f;
 private Quaternion targetRotation;

 void Start () 
 {
 
 
 }
 

 void Update () 
 {

     float acceleration = Input.GetAxis ("Thrust");
     rigidbody.AddForce (transform.forward * acceleration * accelerationForce);
             
     Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"),0,Input.GetAxisRaw("Vertical"));
     if (input != Vector3.zero) {
         targetRotation = Quaternion.LookRotation (input);
         transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetRotation.eulerAngles.y, rotationSpeed *Time.deltaTime);
             }
 }

}

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 truefictionstudios · Nov 18, 2014 at 12:47 AM 0
Share

sorry it took so long to respond. turns out it was being caused by the camera script. thanks for the help though!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Nov 14, 2014 at 05:09 PM

Generally speaking, you should either choose to modify an object kinematically (i.e. you directly set transform.position and transform.rotation in the Update() loop), or you apply forces and let the physics engine resolve the corresponding position and rotation (i.e. use rigidbody.AddForce() in FixedUpdate()).

You're doing a mixture of both, which can have interesting side effects. At the very least, you should move your AddForce() code into FixedUpdate() rather than Update(), and see if that makes a difference.

Comment
Add comment · Show 2 · 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 truefictionstudios · Nov 15, 2014 at 07:52 PM 0
Share

I tried that, no luck

avatar image Linus · Nov 15, 2014 at 07:59 PM 0
Share

Well several things are might cause issues in your example code. Doing what is suggested in the answer would be an improvement. Perhaps add your improved version by editing the question or add a comment to the question. What kind of joystick are you using btw?

Also Input.GetAxisRaw does not take deadzone into consideration among other things

avatar image
0

Answer by Addyarb · Nov 18, 2014 at 01:07 AM

If you press a key, transform.position = vector3.forward... if you let go of that key, let the velocity be a slerp between your current velocity and 0.

Let me know if you need this in code form!

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

move enemy to old position of player 2 Answers

The most effective way to search enemies. 1 Answer

Vector3.RotateTowards Problem 1 Answer

Another question about Skyroads-like moving 0 Answers

Get an Object to Automatically Move Forward 2 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