I am making a strategy game and you can move your units in battle by simply clicking on them once and then the next place you click will have them move there, it works fine in the editor but when i make the build it just moves them to the first click, it is like it interprets one click as two and moves it to the place of your troop that you have selected. How do i fix it? have been working on the game for a few months and even tho its almost complete its useless if the build has such a critical bug(its a windows build on unity 2021.3.8f1)
#Game mechanic works on editor but not on build
1 messages · Page 1 of 1 (latest)
the part that i suspect causes the bug
It would be helpful if you send the code as code and not text
Use codeblocks to send code in a message!
To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.
For example:
```cs
Console.WriteLine("Hello World");
```
Produces:
Console.WriteLine("Hello World");
To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.
Tried to but it was too long, gonna use that site
a powerful website for storing and sharing text and code snippets. completely free and open source.
OnGUI (IMGUI) is pretty much obsolete. You should use a Canvas (uGUI) instead.
In fact, it's not even listed in the UI system comparison anymore: https://docs.unity3d.com/Manual/UI-system-compare.html
As for the error you are facing:
Input checks should only be done inside Update.
Since OnGUI may be called multiple times per frame, checking input there may result in multiple input events seemingly happening - which is what you are experiencing.