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.
↧