So I’m currently trying to convert my Unity game over to Unreal. The “hub” of the game is an endlessly driven road and you use a phone to access other areas. So in Unity, I have 3 long road tiles and they just scroll towards the camera at a given speed (scrollingSpeed) and when they get to a certain point (roadSegmentOffsetStart) they just move forward by a certain distance (roadSegmentOffsetDistance).
The road gameobjects are just kept in a list and every frame I iterate through the list and scroll the road piece backwards and check if it’s met it’s threshold to be translated forward, creating an ever scrolling road.
The camera by the way just remains in place. I found a Unreal tutorial of an endless runner game hoping that would help but I couldn’t figure out how to apply that to my use case as their player just ran forward and the road spawned infront of them. Now in Unity infinitely scrolling forward like this throws floating point errors and eventually makes everything disappear as your axis value gets in the millions so I want to fake it by just having everything in place, scrolling it back, and moving it forward when the camera can no longer see it.
How would I achieve this in Unreal Engine
I’m sorry if this was a little ramble, but I’m not entirely sure on what information is useful and appreciate any help.
Unity Script included if that’s helpful at all.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class WorldScroll : MonoBehaviour
{
[SerializeField] private float scrollingSpeed;
public List<GameObject> roadSegments;
public float roadSegmentOffsetStart;
public float roadSegmentOffsetDistance;
private void Update()
{
for (int i = 0; i < roadSegments.Count; i++)
{
//Infinitly Scroll By Set Speed
roadSegments*.transform.Translate(Vector3.back * Time.deltaTime * scrollingSpeed);
if (roadSegments*.transform.position.z <= roadSegmentOffsetStart)
{
roadSegments*.transform.position = new Vector3(0, 0, roadSegments*.transform.position.z + roadSegmentOffsetDistance);
}
}
}
}