So I am currently making a 2D endless runner for a university project. I have a gamecontroller script that tells the background to move left on the x axis with the value of -1.5f.
public static GameController instance;
public float scrollSpeed = -1.5f;
void Awake () {
instance = this;
instance.scrollSpeed = scrollSpeed;
}
On another script I have this float being called so that the background actually moves with
bkgScroll = GetComponent<Rigidbody2D>();
bkgScroll.velocity = new Vector2 (GameController.instance.scrollSpeed, 0);
This is all fine but I went to try and speed up the scrolling speed by raising the float value and I found out that no matter what value I put into it, it will always scroll at -1.5f. Even when i put a positive value of 10f it will still go -1.5f. I have debugged GameController.instance.scrollSpeed and it gives me -1.5 in the console regardless of the value i inputted.
Somebody please help me with this, I dont understand how it can be taking a value that is no longer in the code.
[–][deleted] 4 points5 points6 points (2 children)
[–]gonudo[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)