How do I make it so I add things to a List every frame but the objects that are added refresh it with out going above the desired point?
EX: This is the script that I want to fix:
public WaterPuddleTeleport WTP;
public GameObject Player;
public float DistanceToPlayer;
// Start is called before the first frame update
void Start()
{
Player = GameObject.FindGameObjectWithTag("Player");
}
// Update is called once per frame
void Update()
{
WTP = GameObject.FindObjectOfType<WaterPuddleTeleport>();
WTP.PuddleDistance.Add(this.gameObject.GetComponent<PuddleScript>().DistanceToPlayer);
DistanceToPlayer = Vector3.Distance(this.transform.position, Player.transform.position);
}
I want to make it so that it refreshes the spot it had in the list.