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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Help-me Easy, error CS0131: The ....

Discussion in 'Scripting' started by juniorforestS, Apr 24, 2017.

  1. juniorforestS

    juniorforestS

    Joined:
    Apr 18, 2015
    Posts:
    47
    public static Transform Spawn(Transform prefab, Vector3 pos, Quaternion rot)
    {

    return (Transform)Object = PhotonNetwork.Instantiate(prefab.name,pos,rot,0);
    }


    result :


    error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Code (CSharp):
    1. public static Transform Spawn(Transform prefab, Vector3 pos, Quaternion rot)
    2. {
    3. Transform t = PhotonNetwork.Instantiate(prefab.name,pos,rot,0);
    4. return t;
    5. }
    6.  
     
  3. juniorforestS

    juniorforestS

    Joined:
    Apr 18, 2015
    Posts:
    47
    I need to leave it as it is if I change this error happens

    (46,32): error CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.Transform'

    return Object, help-me
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Code (CSharp):
    1. public static Transform Spawn(Transform prefab, Vector3 pos, Quaternion rot)
    2. {
    3. Transform t = PhotonNetwork.Instantiate(prefab.name,pos,rot,0).transform;
    4. return t;
    5. }
     
    juniorforestS likes this.
  5. juniorforestS

    juniorforestS

    Joined:
    Apr 18, 2015
    Posts:
    47
    thanks methos5k <3
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    no problem :)