Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Error BCE0077 Help please.

Discussion in 'Scripting' started by TaleOf4Gamers, Nov 14, 2014.

  1. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    It is not possible to invoke an expression of type 'float'.
    As you can see that i am getting this error when I try to run my game.
    Below is my code and the error is apparently on (69,55)
    Code (JavaScript):
    1. //public vars[/B]
    2. [B]var gameName:String = "A generic FPS";[/B]
    3. [B][/B]
    4. [B][/B]
    5. [B]//private var booleans[/B]
    6. [B]private var refreshing:boolean;[/B]
    7. [B][/B]
    8. [B]//private vars[/B]
    9. [B]private var hostData:HostData[];[/B]
    10. [B]private var btnX:float;[/B]
    11. [B]private var btnY:float;[/B]
    12. [B]private var btnW:float;[/B]
    13. [B]private var btnH:float;[/B]
    14. [B][/B]
    15. [B]function Start (){[/B]
    16. [B]    btnX = Screen.width * 0.05;[/B]
    17. [B]    btnY = Screen.width * 0.05;[/B]
    18. [B]    btnW = Screen.width * 0.1;[/B]
    19. [B]    btnH = Screen.width * 0.1;[/B]
    20. [B]}[/B]
    21. [B][/B]
    22. [B]function startServer(){[/B]
    23. [B]    Network.InitializeServer(32, 25001, !Network.HavePublicAddress);[/B]
    24. [B]    MasterServer.RegisterHost(gameName, "My first game", "A my first game");[/B]
    25. [B]   [/B]
    26. [B]}[/B]
    27. [B][/B]
    28. [B]function refreshHostList(){[/B]
    29. [B]    MasterServer.RequestHostList(gameName);[/B]
    30. [B]    refreshing = true;[/B]
    31. [B]}[/B]
    32. [B][/B]
    33. [B]function Update (){[/B]
    34. [B]    if(refreshing){[/B]
    35. [B]        if(MasterServer.PollHostList().length > 0){[/B]
    36. [B]            refreshing = false;[/B]
    37. [B]            Debug.Log(MasterServer.PollHostList().length);[/B]
    38. [B]            hostData = MasterServer.PollHostList();[/B]
    39. [B]        }[/B]
    40. [B]    }[/B]
    41. [B]}[/B]
    42. [B][/B]
    43. [B]//Displays a message when the server has started[/B]
    44. [B]function OnServerInitialized(){[/B]
    45. [B]    Debug.Log("Server Started");[/B]
    46. [B]}[/B]
    47. [B][/B]
    48. [B]function OnMasterServerEvent(mse:MasterServerEvent){[/B]
    49. [B]    if(mse == MasterServerEvent.RegistrationSucceeded){[/B]
    50. [B]        Debug.Log("Registration sucessfull");[/B]
    51. [B]    }[/B]
    52. [B]}[/B]
    53. [B][/B]
    54. [B][/B]
    55. [B]//Buttons for the server stuff[/B]
    56. [B]function OnGUI(){[/B]
    57. [B]    if(GUI.Button(Rect(btnX, btnY, btnW, btnH), "Start Server")){[/B]
    58. [B]        Debug.Log("Starting Server");[/B]
    59. [B]        startServer();[/B]
    60. [B]    }[/B]
    61. [B]   [/B]
    62. [B]    if(GUI.Button(Rect(btnX, btnY * 1.2 + btnH, btnW, btnH), "Refresh list")){[/B]
    63. [B]        Debug.Log("Refreshing");[/B]
    64. [B]        refreshHostList();[/B]
    65. [B]    }[/B]
    66. [B]}[/B]
    67. [B][/B]
    68. [B]    for(var i:int = 0; i<hostData.length; i++){[/B]
    69. [B]        GUI.Button(Rect(btnX*1.5 + btnW, btnY*1.2 (btnH*i), btnW*3, btnH*0.5), hostData[i].gameName);[/B]
    70. [B]    }

     
    Last edited: Nov 14, 2014
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    You still haven't put in the missing operator on line 69, inbetween the expressions btnY*1.2 and (btnH*i)
     
  3. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    thank,
    Its fine now I just had a dumb moment before lol.