Hello,
When i play my game/project in unity, everything works fine.
But when i build and run the game/project things begin to just randomly not work. e.g. No Muzzle flash , GuiText does not work, a spinning object beings to spin 10x than what it script tells it to.
What am i doing wrong? or is this a fault with unity?
The spinning object going 10X faster than it does in the editor suggests that your code isn’t properly framerate-independent. Use Time.deltaTime where necessary.
– This is not the entire script, only the piece that i think may be problematic –
( In unity everything works, in a built version it does not, the guitext appears but without any of the variables (numbers, something wrong with ‘ToString?’ or maybe both clips bullet left being in the same update function could be a problem? )
(Script on character controller) - Part 1
private var machineGun : MachineGun;
function UpdateGUI () {
// Update machine gun gui*
// Machine gun gui is simply drawn with a bullet counter text*
The significant bit of the code was the OnGUI function, actually. A problem can sometimes occur if you use fixed pixel offsets to position GUI elements. The screen size is often different in the built player than in the editor. GUI elements that are positioned in a corner, say, can be offscreen in the finished player. Use the Screen class to position elements relative to the current screen size.