The variables modified in the inspector are not kept on build
Hi! I modified some variable named "speed" from a script in the inspector - it defines the value of the cars' speed in my game - and it's working in the editor player, but when I build the game the speed is kept as it was before I modified it. What's the logic of that?! *The script was attached to prefabs so I used the same script(s) for more prefabs with different speed. Here are the scripts if it matters:
MoverToLeft
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class MoverToLeft : MonoBehaviour { public float Speed; private Rigidbody2D rb;
void Start()
{
rb = this.GetComponent<Rigidbody2D>();
rb.velocity = new Vector2(-Speed, 0);
}
}
MoverToRight
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class MoverToRight : MonoBehaviour { public float Speed; private Rigidbody2D rb;
void Start()
{
rb = this.GetComponent<Rigidbody2D>();
rb.velocity = new Vector2(Speed, 0);
}
}
I hope you can help me, thanks!
Probably a stupid question, but did you make the changes to Speed while in play mode?