x


2 Bugs in my game: mouse control takes some time to load and Menu not working.

Ok people once again i surrender to your knowledge. Here's my question. I'm having two bugs happening inside my game.

It's a tank game and the first question is related to the tank control. So i have a script to make it move wich is applied to the general object. I have then two sub-scripts that control his tower and his cannon. They are as simple as this....


var verticalSpeed : float = 2.0;
function Update () {
    //Mouse delta (não varia entre -1 e 1)
    var v : float = verticalSpeed * Input.GetAxis ("Mouse X");
    //Debug.Log(Input.GetAxis("Mouse X"));
    transform.Rotate (0, 0, v);
}

The horizontal one is the same. The problem with this script, and i don't know why, when i start the game i can control the overall tank but this mouse control takes like 5 seconds or more to be loaded and get me control over my cannon. Why is this happening? is something related to unity's loading script order memory or so?

The other bug that i have in my game here is related to the menu. I have this script over two buttons in my main menu, the buttons are simply a 3d text with a box collider applied to them.


var levelToLoad : String;
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;
function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
if(QuitButton){
Application.Quit();
}
else{
Application.LoadLevel(levelToLoad);
}
}
@script RequireComponent(AudioSource)

And in my main menu i have this script that is assessed by a script to check the esc button:


var menuHeight:float=500;
var menuWidth:float=500;
var buttonSpacing:float=25;
var mainMenu: String = "MainMenu";
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;

function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-menuWidth/2,Screen.height/2-menuHeight/2,menuHeight,menuWidth),customStyle);
GUILayout.Space(50);
GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Main Menu")){
Application.LoadLevel(mainMenu);
}
GUILayout.Space(buttonSpacing);
if(GUILayout.Button("Exit to Desktop")){
Application.Quit();
}
GUILayout.Space(buttonSpacing);
GUILayout.EndArea();
}

The problem here is that if i play my game from the beginning there is no problem pressing the play menu button and start the game or pressing quit to exit app, but once i use the pause menu to go back to the main menu these two buttons (play game and quit) don't work anymore... Is this a unity's bug or am i missing something?

Thanks a lot guys, hope you can help me solve this problem. I'll be glad to hear from you. :D

more ▼

asked Jul 11 '12 at 10:08 AM

Satamanster gravatar image

Satamanster
19 1 6 8

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3689
x3331
x983
x788
x510

asked: Jul 11 '12 at 10:08 AM

Seen: 271 times

Last Updated: Jul 11 '12 at 10:08 AM