This is my script to move game objects along the x axis.
public class MoveObjects : MonoBehaviour
{
public static float speed;
private void Start()
{
speed = 7.5f;
}
private void Update()
{
this.transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0));
speed += Time.deltaTime * 0.1f;
}
}
When I called the speed variable outside of the class it gives me 0. That does not make sense. I could not find any solutions. What could be the problem? Thank you for your time.
Note: I debugged like
Debug.Log(MoveObjects.speed);
Debug.Log(MoveObjects.speed*Time.deltaTime);