Question by
unity_21292651 · Nov 19, 2018 at 07:10 PM ·
velocityspeedbackgroundaccelerationscrolling
Acceleration problem with infinite scrolling background
Hi guys.
I'm trying to make my infinite scrolling background to go a bit faster every second, which should work with this code (I use it for the same thing with gravity with different object). The problem is:
Acceleration... It goes incredibly slow at the beginning and incredibly fast after some (little) time no matter what values I use (100f). So there must be something wrong .. I need it to accelerate slowly, not like a jaguar.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
Material material;
Vector2 offset;
public int xVelocity, yVelocity;
private void Awake()
{
material = GetComponent<Renderer>().material;
}
// Use this for initialization
void Start()
{
offset = new Vector2(xVelocity, yVelocity);
}
// Update is called once per frame
void Update()
{
material.mainTextureOffset += offset * Time.timeSinceLevelLoad / 100f;
}
}
I've been hitting my head against the wall for this for over three hours and can't figure it out.. pls help.
Comment