-So, I followed a tutorial to make a basic Flappy bird game and I wanted to try and increase pipe movement speed based on the score the player has. The problem I ran into is that when trying to change moveSpeed by adding the playerScore, the pipes would stopped moving.
public class PipeMovement : MonoBehaviour
{
private int moveSpeed = 10;
private float deadzone = -40;
LogicScript logicScript;
void Start()
{
logicScript = GameObject.Find("Logic").GetComponent<LogicScript>();
}
// Update is called once per frame
void Update()
{
moveSpeed += logicScript.playerScore;
transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
-For reference here is the LogicScript I’m using to track score
public class LogicScript : MonoBehaviour
{
public int playerScore = 0;
public Text ScoreText;
public GameObject gameOverScreen;
[ContextMenu("Increase Score")]
public void addScore(int scroeToAdd)
{
playerScore = playerScore + scroeToAdd;
ScoreText.text = playerScore.ToString();
}
I have managed to use the code to check for Bool true\false values but int I cant figure out