Question by
gawoon · Jul 15, 2018 at 05:46 AM ·
movementmovement scriptmove an objectjitterjittering
my box movements look jitter, how to fix it
here's my problem. https://youtu.be/fckdSE3e_1s
i put my script to the box and do the movements in the FixedUpdate.
as i know, the movement should be handled in the FixedUpdate and presents it in the LateUpdate. for example, physics movements are calculated in each script's fixedupdate and the sprite renderer position set up in each script's lateupdate.
give me any advice to fix it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour {
public enum Where
{
EUpdate,
EFixedUpdate,
ELateUpdate
}
public float Speed = 2f;
public Where updateType = Where.EUpdate;
// Update is called once per frame
void Update ()
{
if(updateType == Where.EUpdate)
{
Move();
Debug.Log("Update");
}
}
void FixedUpdate()
{
if (updateType == Where.EFixedUpdate)
{
Move();
Debug.Log("FixedUpdate");
}
}
void LateUpdate()
{
if (updateType == Where.ELateUpdate)
{
Move();
Debug.Log("LateUpdate");
}
}
public void Move()
{
transform.position += (new Vector3(Speed, 0, 0) * Time.deltaTime);
}
}
Comment
it looks okay but at the certain point, it seems the box moves forward and back.