@
@
@programmer2020-08-30 22:58:41
C++ / C#
@programmer, 2020-08-30 22:58:41

How to reset variable values ​​on level reload?

when restarting the level with SceneManager.LoadScene("play"); values ​​are not reset to their original position. as I understand it because of the value of the static field, how can I solve this?
5f4c02f1abf70302829746.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-08-31
@freeExec

Get rid of static

R
ReWire_92, 2020-09-01
@ReWire_92

SCORE = GameObject.Find("deletepanel").GetComponent<score>();

Just blood from the eyes :O
If the reference to the object does not change during the execution of the program, then why not make the SCORE variable public instead of this cumbersome and resource-intensive construction and drag the desired object into the field in the inspector?
public score SCORE;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question