Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by abdulelah444 · Apr 01, 2019 at 05:01 PM · movementcharactercontroller2d-platformerjerky

Why is my character movement jerky/stuttry/jettry?

Hi , I'm trying to make a 2D game and I'm trying to nail the movement down, but no matter what I use it's always as I described it in the title, until I tumbled upon a characterController2D script made by Prime31 and when I used it the movement became buttery smooth in the right way I wanted to do it, I tried to understand the gentleman's code but I'm not an expert so im still in the process of understanding it

this is a video to show the difference between my movement code (bottom cube) and prim31's script (top cube)

The video

here is prime31's code on Github, and for me I used all possible ways of movement that I know of, through the rigidbody and or through the transform

so if I can get some insight on how to get same results without having to use prime31's code or at least how I could improve the jerkiness seen in video

pardon my English , thank you

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 xxmariofer · Apr 01, 2019 at 08:02 PM 0
Share

you need to share your code for us to help you, but it feels like you are using fixedupdate/update wrong, update is called every frame so its where you should do the movement, if you are using rigidbodys or any other physics use the fixedupdate.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by KingKong320 · Apr 09, 2019 at 06:51 AM

@xxmariofer this is the script attached on camera

 public Transform leftSideLimt, rightSideLimit;
 
 public GameObject FollowTargetOBJ;
 public float FollowSpeed;

 //Paralax layers
 public GameObject[] BackgroundROOTS;



 private bool PlayerJustDied;


 void Start ()
 {
     FollowTargetOBJ = GameObject.FindGameObjectWithTag ("Player");

 
 }


 void FixedUpdate ()
 {
     if (PlayerJustDied == false && FollowTargetOBJ.transform.position.x > leftSideLimt.position.x && FollowTargetOBJ.transform.position.x < rightSideLimit.position.x) {
         //Smoothly Follow Target
         Vector3 PositionBefore = transform.position;
         Vector3 NewPosition = Vector3.Lerp (transform.position, FollowTargetOBJ.transform.position, FollowSpeed * Time.deltaTime);
 
         transform.position = new Vector3 (NewPosition.x + 2.5f, NewPosition.y + 1.3f, transform.position.z);
 
         //Paralax layer movement
         Vector3 CameraMovementAmount = PositionBefore - this.transform.position;
 
         BackgroundROOTS [0].transform.Translate (-CameraMovementAmount * 0.8f);
 
     }
 
 }

i set interpolate to interpolate..it started jerks,but when i set interpolate to none camera follows fine but characters movement is not smooth.Please help me out

Comment
Add comment · Show 3 · 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 xxmariofer · Apr 09, 2019 at 07:21 AM 0
Share

first change the FixedUpdate to the Update, i thought your issue was the player not being smooth not the camera

avatar image KingKong320 xxmariofer · Apr 10, 2019 at 04:04 AM 0
Share

i have done that but that did not fix in update :(.... And my character is moving smoothly but not the camera is following it smoothly...i have attached this script on empty gameobject and that empty gameobject contains 2 cameras in scene,,one is following background and the other is following character.

avatar image xxmariofer KingKong320 · Apr 10, 2019 at 07:34 AM 0
Share

ok try changing this 2 lines

 Vector3 NewPosition = Vector3.Lerp (transform.position, FollowTargetOBJ.transform.position, FollowSpeed * Time.deltaTime);
  
 transform.position = new Vector3 (NewPosition.x + 2.5f, NewPosition.y + 1.3f, transform.position.z);

to this

     Vector3 NewPosition = Vector3.Lerp (transform.position, FollowTargetOBJ.transform.position  + new Vector3(2.5f, 1.3f, 0.0f), FollowSpeed * Time.deltaTime);
      
     transform.position = new Vector3 (NewPosition.x, NewPosition.y, transform.position.z);



avatar image
0

Answer by zakkaiokenx10 · Apr 09, 2019 at 07:18 AM

Please use a cinemachine 2d camera and make it follow the player. That will help you better than hard coding a new camera, as well as giving you features you'll enjoy..

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

242 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 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 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

2D plaformer, Can bug me into wall 2 Answers

Help 2D attack 1 Answer

CharacterController.Move isn't setting collision flags 1 Answer

How can I adapt this character controller movement script to allow movement in mid air? 0 Answers

Cant get dash attack working 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