Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Jerky movement when the player is falling.

Discussion in 'Editor & General Support' started by mvii3iv, Jul 26, 2014.

  1. mvii3iv

    mvii3iv

    Joined:
    Jul 20, 2014
    Posts:
    16
    Hi!
    I am experimenting a jerky movement in my current game when the player is falling, I am new in unity! so I don´t know if I am doing something wrong!.

    I´ve attached a youtube video which shows the problem at the end of the video, when the character is falling down the movement is so jerky.

    This is my code just in case something is wrong with it:





    using UnityEngine;
    using System.Collections;

    public class PlayerMovement : MonoBehaviour {

    public bool grounded = false;
    public Transform groundedEnd;

    public float speed = 6f;
    public float jumpForce = 300f;


    // Use this for initialization
    void Start () {

    }


    void Update()
    {
    Movement();
    }

    void Movement()
    {

    //Debug.DrawLine(this.transform.position, groundedEnd.position, Color.green);
    //grounded = Physics2D.Linecast (this.transform.position, groundedEnd.position, 1 << LayerMask.NameToLayer("Platforms"));

    if(Input.GetKey(KeyCode.D))
    {
    transform.Translate(Vector2.right * speed * Time.deltaTime);
    }
    if(Input.GetKey(KeyCode.A))
    {
    transform.Translate(-Vector2.right * speed * Time.deltaTime);
    }
    if (Input.GetKeyDown (KeyCode.W) )
    {
    rigidbody2D.AddForce(Vector2.up * jumpForce);
    }


    /*
    currentAngle = transform.rotation.z;

    if (currentAngle < .2 && !grounded)
    {
    transform.Rotate (Vector3.forward * 1);
    }
    */

    }
    }
     
    Last edited: Jul 26, 2014
  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Do you use a camera script?
     
  3. Josh-Naylor

    Josh-Naylor

    Administrator

    Joined:
    Jul 1, 2014
    Posts:
    216
  4. mvii3iv

    mvii3iv

    Joined:
    Jul 20, 2014
    Posts:
    16
    Yes, I'm using a camera script