- Home /
Question by
sky8460 · Dec 30, 2016 at 09:23 AM ·
c#background
Moveing Background Is Jerking to much !!!
using UnityEngine; using System.Collections;
public class LayerScript : MonoBehaviour {
public float Speed;
public Transform OtherPiece;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(GameManager.Instance.CurrentGameState == GameState.InGame)
{
if (transform.position.x < -35.5f) {
transform.position = new Vector3(OtherPiece.position.x,this.transform.position.y,0);
} else {
transform.Translate (-1 * Speed * Time.deltaTime, 0, 0);
}
}
}
}
Comment
Answer by arkrp · Dec 31, 2016 at 01:01 PM
i recomend you use sin and cosine functions if you want smooth movement
Answer by nathanthesnooper · Dec 31, 2016 at 05:18 AM
If OtherPiece.x is greater than -35.5, it will jerk because it will begin to translate left again and then go back to OtherPiece.position.x when it is less than -35.5.
Just recommending for you to either post a video or be more specific when you say 'jerking' ( ͡° ͜ʖ ͡°)
Your answer
![](https://koobas.hobune.stream/wayback/20220612103713im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Spawning game Object after a period of time 2 Answers
How do I clear my screen after changing resolution? 1 Answer