How can I make this translation smoother?
I am moving a platform (technically there are two objects of the same platform) to the left until at certain point at which I reset it back so that it gives off the illusion of a repeating platform. The problem is this still looks fairly choppy. Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScrollingObject : MonoBehaviour
{
public float speed;
Vector3 startPos;
void Start()
{
startPos = transform.position;
}
void Update()
{
transform.Translate ((new Vector3 (-1, 0, 0)) * speed * Time.deltaTime);
if (transform.position.x < -22.71982)
{
transform.position = startPos;
}
}
}
I'm not entirely sure why this causes the platform to look choppy while moving. Do anyone have any ideas? Any suggestions would be much appreciated. Thank you in advance.
Comment
Your answer
Follow this Question
Related Questions
Trying to Generate Different Random Values for Position of Game Object Instances [C#] 1 Answer
Y value in transform.Translate when not grounded - gravity problem 0 Answers
Increase velocity of gameObject every time it spawns? 1 Answer
Transform constant moving in scene even if translated for Vector3.zero 1 Answer