- Home /
This makes no sense help, pls help
I have a script that once it is activated, does some very simple things, references 2 different game objects, references a script on each, then changes a variable, except, it works great with one and not at all with the other, it has no errors it just doesn't change the variable public class GameEnder : MonoBehaviour {
// Use this for initialization
void Start () {
GameObject ender = GameObject.Find("Player 2(Clone)");
GameObject darkness = GameObject.Find("Darkness2");
Player2 P2 = ender.GetComponent<Player2>();
erty erty = darkness.GetComponent<erty>();
erty.h = +0.005f;
P2.end = +1;
}
// Update is called once per frame
void Update () {
}
} p2 is the on that doesnt work pls help
What is "end" and how is it declared? Also why do you have a "+" in front of your values? Those don't do anything.
Answer by MarioSantoso · Apr 14, 2018 at 12:01 AM
What is the original value of P2.end?
Are you trying to increment or set a value? If you plan to increase then use
P2.end += 1;
as P2.end = +1; will always set the value to 1;
Your answer
![](https://koobas.hobune.stream/wayback/20220612160711im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Referencing all objects in scene 2 Answers
trouble with referencing a componenet (bool) 1 Answer
Instantiated Objects dont get their Script referenced properly 2 Answers
why doesn't my reference work? 1 Answer
Using a Scriptable Object as a Config 0 Answers