Hey, i know this is very basic stuff but could you help? Initially i wanted when player score == 5, velocity would rise but after it’s increased is goes down to startMoveSpeed. I just got back to this code after a while and i don’t remember what is what
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PipeMoveScript : MonoBehaviour
{
public LogicScript logic;
public BirdScript bird;
public float startMoveSpeed = 10f;
public float acceleration = 0.5f;
public float currentMoveSpeed;
public float maxSpeed = 30f;
public float lastSpeed;
void Start()
{
logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
currentMoveSpeed = startMoveSpeed;
lastSpeed = currentMoveSpeed;
}
void Update()
{
transform.position += (Vector3.left * currentMoveSpeed) * Time.deltaTime;
if (transform.position.x < -35f)
{
//Debug.Log("Pipe deleted");
Destroy(gameObject);
}
if (logic.playerScore % 5 == 0 && logic.playerScore != 0 && BirdScript.birdisAlive == true)
{
pipeAcceleration();
}
}
void pipeAcceleration()
{
currentMoveSpeed += 2f * Time.deltaTime;
lastSpeed = currentMoveSpeed = Mathf.Clamp(currentMoveSpeed, startMoveSpeed, maxSpeed);
Debug.Log("CurrentMoveSpeed: " + lastSpeed);
}
}