Hello. I am making a hyper-casual game in Unity. I am currently working on the gates that have numbers like “x2” or “+50k” or “-7k”. I assume you already know how these gates work. But the problem is… For some reason, the variables are working as static. If I assign the gate script to one gate. It works perfectly without any problems. But if I make 2 gates & assign the same script to the 2 gates. Both gates do only one modification.
Example: First gate is set to +500. Second gate is set to -600. If I play the game and collide with the first gate. I get +500. But if I collide with the second gate. I still get +500. But… I am supposed to get -600.
Thats the problem. This is my script. Please help me.
script has been removed
Please help me on this one. I have been stuck for 2 days now!
[SOLVED: The collider wasn’t moving with the player.]
What you describe above sounds simply like you wrote a bug.
And that means… time to start debugging!
You have a lot of duplicated code in there, which will make it hard to test and debug. You may wish to make some helper formatting functions, or learn to use the native C# numeric formatting functionalities (see Google for how).
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...);
statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
[SOLVED] The problem was that the collider of the player wasn’t moving with the player. So I changed the collider from the player to the player’s model and it works now!
I found the solution a few weeks ago but I forgot to change it here!