• 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 saif301299 · 13 hours ago · unity 2d2d-physicsrpgtop down shooter2dmovement

2d Top Down Shooter Jerky Movement

Hey guys I am a newbie in unity. Currently I am making a 2d top down shooter based game. And here comes the bug. So character movements I am using Brackeys top down shooting tutorial. And here is the code.

using System.Collections;
using System.Collections.Generic; using UnityEngine; public class PlayerMovement :MonoBehaviour

{

 [SerializeField]private float movementSpeed = 5f;
  [SerializeField]private Camera cam;
   private Rigidbody2D playerRb;
   private Vector2 movmentVector;
   private Vector2 mosusePos;
   private Vector2 lookDirectionVec;

 
  //Start Called once
  private void Start()
  {
      playerRb = gameObject.GetComponent<RigidBody2D>();
 
  }
 
  //Update Called Every Frame
     private void Update()
   {
       GetingInput();
      MouseRotation();
  }
 
  //Fixed Update 
  private void FixedUpdate()
  {
      playerRb.MovePosition(playerRb.position
          + movmentVector * Time.fixedDeltaTime);
      // playerRb.velocity = new Vector2(movmentVector.x, movmentVector.y);
  }
 
  private void GetingInput()
  {
      Vector2 inputVector = new Vector2(Input.GetAxisRaw("Horizontal"),Input.GetAxisRaw("Vertical"));
      movmentVector = inputVector.normalized *movementSpeed;
 
      lookDirectionVec = cam.ScreenToWorldPoint(Input.mousePosition) - transform.position;
  }
  private void MouseRotation()
  {
      float angleToRotate  = Mathf.Atan2(lookDirectionVec.y,lookDirectionVec.x) * Mathf.Rad2Deg - 90f;
      Quaternion qRotation = Quaternion.AngleAxis(angleToRotate,Vector3.forward);
      transform.rotation = qRotation;
  } 

}

But whenever I test the game the movements are jittering. Like the shutter the movement. I found some solutions on web articles and unity forms. The first I tried is to change RigidBody2d.MovePositions() to RigidBody2d.Velocity but the result is also the same and the second one is to change the camera size 5 to 10. Second one is kind of a work but it stills jittering. So any solutions to this. Here are the camera properties alt text and player properties.alt text

playre-setting.jpg (64.7 kB)
camera-setting.jpg (74.0 kB)
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 saif301299 · 13 hours ago 0
Share

Ok guys I still learning how to ask questions.....

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.

Follow this Question

Answers Answers and Comments

164 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

Related Questions

good tutorials for 2d action rpg?,Good tutorials on 2D action-rpg? 1 Answer

Does anyone know how to fix this unity 2d movement isssue? X axis movement not working 0 Answers

Unity 2D player sticks on platform corners 2 Answers

Pixel perfect crosshair. 1 Answer

Make the bullet in a 2d Top Down shooter get destroyed after passing mouse position 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