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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

No overload for method `CreateRoom' takes `6' arguments Cannot convert type `UnityEngine.Transform

Discussion in 'Scripting' started by FedeStefan, Nov 20, 2018.

  1. FedeStefan

    FedeStefan

    Joined:
    Aug 15, 2018
    Posts:
    221
    I fixed this.
     
    Last edited: Sep 14, 2021
  2. FedeStefan

    FedeStefan

    Joined:
    Aug 15, 2018
    Posts:
    221
  3. FedeStefan

    FedeStefan

    Joined:
    Aug 15, 2018
    Posts:
    221
  4. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    You don't need to bump your thread every 15 minutes. There's barely ~50 posts a day here.

    The errors are incredibly descriptive and should be easy to fix.

    Cannot convert type `UnityEngine.Transform' to `UnityEngine.GameObject' via a built-in conversion
    This means that you're passing a Transform to a function but it's expecting a GameObject.

    No overload for method `CreateRoom' takes `6' arguments

    This one is obvious. You're passing too many (or too few) values to a function.

    The name `rotation' does not exist in the current context
    This means you're trying to reference a variable that doesn't exist.

    Learning how to debug and resolve these common issues is paramount to your success. Good luck.
     
    Suddoha likes this.
  5. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824

    If the error refers to that code snippet, then you're likely trying to instantiate a transform (ShotGun.bullet), which cannot be casted to GameObject - neither implicity nor explicitly.

    Ther are multiple ways you can fix that:

    #1: Remove the cast operation (as GameObject) and declare the local variable 'instantiatedBullet' as a Transform variable (or use 'var' for automatic type inference).

    #2: Turn the bullet field/property into a field/property of type GameObject - the cast with the as-operator can be removed here as well

    #3: Use ShotGun.bullet.gameObject for the instantiation. The cast can still be removed.

    Any proper IDE should show all the available overloads of that methods. Anyway, here are the available overloads according to the documentation (no guarantee that's up to date - I've never used Photon Networking)

    static bool CreateRoom (string roomName)
    static bool CreateRoom (string roomName, RoomOptions roomOptions, TypedLobby typedLobby)
    static bool CreateRoom (string roomName, RoomOptions roomOptions, TypedLobby typedLobby, string[] expectedUsers)

    And you're using
    Code (CSharp):
    1. CSharpPhotonNetwork.CreateRoom(newRoomName, true, true, maxPlayers, setMapName, exposedProps);
    Assuming that the docs are up to date, that overload does not exist.


    If that's supposed to refer to the rotation used in
    firePoint.rotation
    then firePoint's type does not declare any member that is named rotation (though that would be a different error). I assume it's a Transform and it's not the line of code that the error complains about.
    So it might point to another line of code, i.e it hasn't been defined inside that scope.
     
  6. FedeStefan

    FedeStefan

    Joined:
    Aug 15, 2018
    Posts:
    221
    Fixed this.
     
    Last edited: Sep 14, 2021